2013-05-22 18 views
3

我一直訪問p:picklist第一次,我面臨的問題是我無法獲得更新源和目標值的p:picklist ui。我正在使用DualListModel<String>的列表。這裏的代碼..p:pickList不更新源和目標

請幫助我。 感謝您的幫助!

code.xhtml

<p:dataTable value="#{updateSiteObj.dsList}" var="pickListObjDS" > 
    <p:column headerText="DS"> 
     <p:pickList id="pojoPickListDSID" value="#{pickListObjDS}" var="ds" itemValue="#{ds}" itemLabel="#{ds}" showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains" style="border-color: white!important" onTransfer="ajaxSubmit3()"> 
      <f:facet name="sourceCaption">Available</f:facet> 
      <f:facet name="targetCaption">To be removed</f:facet> 
     </p:pickList> 
     <p:remoteCommand action="#{updateSiteObj.onDSTransfer}" name="ajaxSubmit3"/> 
    </p:column> 
</p:dataTable> 

UpdateSite.java

@ManagedBean(name = "updateSiteObj") 
@SessionScoped 
public class UpdateSite { 

    private List<DualListModel<String>> dsList = new ArrayList<DualListModel<String>>(); 

    public List<DualListModel<String>> getDsList() { 
     return dsList; 
    } 

    public void setDsList(List<DualListModel<String>> dsList) { 
     this.dsList = dsList; 
    } 

    public String updateSiteDetails() { 

     ds.add(sg.getPrimaryDSID()); 
     if (sg.getSecondaryDSID() != null) { 
      ds.add(sg.getSecondaryDSID()); 
     } 

     System.out.print("DS:" + sg.getPrimaryDSID() + "=>" + sg.getSecondaryDSID()); 
     DualListModel<String> tempDS = new DualListModel<String>(); 
     tempDS.setSource(ds); 
     dsList.add(tempDS); 
     return "someSite?faces-redirect=true"; 
    } 

    public void onDSTransfer() { 
     System.out.print("DSTransfer"); 
     for (DualListModel<String> str1 : dsList) { 
      System.out.print("RemovedLBEntry:"); 
      for (String dsName1 : str1.getTarget()) { 
       System.out.print("RemovedLB:" + dsName1); 
      } 
     } 
    } 
} 

當我嘗試從源面板移動的數值目標面板picklist UI不顯示來自目標的任何值之後調用onDSTransfer

+0

您的領料單的欄位在哪裏? –

+0

我不明白..列將被添加基於項目標籤,這已經有 – coder123

+1

我認爲這是轉換器問題。請檢查你的會議者。 – herry

回答

1

p:remoteCommand中加上update="@all"

你正在做一個ajax調用,而不是更新你的用戶界面。

<p:remoteCommand action="#{updateSiteObj.onDSTransfer}" name="ajaxSubmit3" update="@all"/> 
+0

對於基本的正常更新使用'update =「@ all」'是不好的做法。這應該只用於特殊情況,這不是我認爲的其中之一。找到其他可以更新的內容... – Kukeltje