简体   繁体   中英

p:pickList doesn't update the source and target

I have been accessing the p:picklist for the first time and I am facing a issue where I am not able to get source and target values updated as in the p:picklist ui. I am using list of DualListModel<String> . Here is the code..

Please help me. Thanks for the help!

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

When I try to call onDSTransfer after moving the values from source panel to target panel in picklist UI doesn't show any value from target.

Add update="@all" in p:remoteCommand .

You are doing a ajax call and not updating your UI.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM