0

当您按下命令按钮时,列表项目应从一个列表添加到另一个列表。第一次,它工作正常,项目移动,但第二次新的替换以前添加的,字符串字段工作正常。当它在本地运行时,它工作正常,但上传到 cloude 没有。

@ManagedBean
@SessionScoped
public class SmsBean implements Serializable {

    private static final long serialVersionUID = 1L;



    private List<SelectItem> listOfDevices=new LinkedList<SelectItem>();
    private List<SelectItem> listOfSelectedDevices=new LinkedList<SelectItem>();
    private List<Device> toAdd=new LinkedList<Device>();
    private List<Device> toDelete=new LinkedList<Device>();



    public SmsBean(){
         List<Entity> entities = Datastore.getTotalDevices();
         if(entities!=null){
            for(Entity et :entities){
                Device device=new Device((String)et.getProperty(DEVICE_DEVICE_NAME_PROPERTY),(String)et.getProperty(DEVICE_MAIL_PROPERTY),(String)et.getProperty(DEVICE_REG_ID_PROPERTY));
                listOfDevices.add(new SelectItem(device));

            }
         }



    }



    public void addDevices(){
        int temp=0;
        for(Device dev:toAdd){
            for(int j=0;j<listOfDevices.size();j++){
                if(((Device)listOfDevices.get(j).getValue()).equals(dev)){
                    temp=j;
                    break;                  
                }
            }
            listOfSelectedDevices.add(listOfDevices.get(temp));
            listOfDevices.remove(temp);

        }
        toAdd.clear();
    }


    public void deleteDevices(){
        int temp=0;
        for(Device dev:toDelete){
            for(int j=0;j<listOfSelectedDevices.size();j++){
                if(((Device)listOfSelectedDevices.get(j).getValue()).equals(dev)){
                    temp=j;
                    break;      
                }
            }
            listOfDevices.add(listOfSelectedDevices.get(temp));
            listOfSelectedDevices.remove(temp);

        }
        toDelete.clear();
    }

}

看法

                        <h:panelGrid columns="4" style="height:100%">
                            <p:selectManyMenu style="height:230px;width:150px;"
                                id="selectedDevices" value="#{smsBean.toDelete}"
                                converter="deviceConverter">
                                <f:selectItems value="#{smsBean.listOfSelectedDevices}" />
                            </p:selectManyMenu>

                            <p:commandButton actionListener="#{smsBean.deleteDevices}"
                                icon="ui-icon ui-icon-circle-triangle-e" process="@form"
                                update="devices" title="Icon Only" />

                            <p:commandButton actionListener="#{smsBean.addDevices}"
                                process="@form" update="selectedDevices"
                                icon="ui-icon ui-icon-circle-triangle-w" title="Icon Only" />

                            <p:selectManyMenu id="devices" value="#{smsBean.toAdd}"
                                converter="deviceConverter" style="height:230px;width:150px;">
                                <f:selectItems value="#{smsBean.listOfDevices}" />
                            </p:selectManyMenu>




                        </h:panelGrid>
4

0 回答 0