p:pickList不更新源和目标

时间:2013-05-22 13:44:32

标签: jsf jsf-2 primefaces

我第一次访问p:picklist并且我遇到了一个问题,我无法像p:picklist ui那样更新源和目标值。我正在使用DualListModel<String>列表。这是代码..

请帮帮我。 谢谢你的帮助!

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);
            }
        }
    }
}

当我在onDSTransfer中将值从源面板移动到目标面板后尝试调用picklist时,UI不显示目标值。

1 个答案:

答案 0 :(得分:2)

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

您正在进行ajax调用而不是更新UI。

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