数据表中的 f:setpropertyactionlistener 不会给我当前行,而是它总是给我最后一个对象..请帮助。谢谢!
代码.xhtml
<p:dataTable id="datatableid" value="#{updateSiteObj.emsList}" var="pickListObjEMS" >
<p:column headerText="EMS">
<p:pickList id="pojoPickListEMSID" value="#{pickListObjEMS.serverList}" var="ems"
itemValue="#{ems}" itemLabel="#{ems}" style="border-color: white!important" onTransfer="ajaxSubmit1()">
<f:facet name="sourceCaption">Available</f:facet>
<f:facet name="targetCaption">To be removed</f:facet>
</p:pickList>
<p:remoteCommand action="# {updateSiteObj.onEMSTransfer}" name="ajaxSubmit1" >
<f:setPropertyActionListener value="# {pickListObjEMS}" target="#{updateSiteObj.tempObj}"/>
</p:remoteCommand>
</p:column>
</p:dataTable>
bean.java
public class UpdateSite {
/** Creates a new instance of UpdateSite */
private List<List<String>> tempEMSList = new ArrayList<List<String>>();
private List<serverList> emsList = new ArrayList<serverList>();
private serverList tempObj = new serverList();
public String updateSiteDetails() {
List<String> source = new ArrayList<String>();
List<String> target = new ArrayList<String>();
for (String[] str : sg.getEMSDetailsList()) {
source.add(str[0]);
}
DualListModel<String> tempSource = new DualListModel<String>(source, target);
serverList obj = new serverList();
obj.setServerList(tempSource);
//here i am adding two objects
emsList.add(emsobj);
}
public void onEMSTransfer() {
System.out.print("tempOBJ size:" + tempObj.getServerList().getSource().size() + "=>" + tempObj.getServerList().getTarget().size());
}
serverList 是一个具有数据类型 DualListModel 变量的类。在 onEMSTransfer 中,我看到第二个对象正在显示,即使我在选择列表中操作第一个对象也是如此。