读取datatable primefaces中复选框的取消选择值

读取datatable primefaces中复选框的取消选择值,primefaces,Primefaces,我有一个带有复选框的数据表供选择。来自db的值在datatable中显示为选中。当通过单击复选框进行新选择时,我可以从数组中读取后端中的值,但是当我取消选中复选框(以取消选择该行)时,该数组仍然包含选中的复选框信息。我希望数组在提交时只包含复选框信息(以便我可以从数据库中删除未选中的复选框)。这是密码- <p:dataTable id="stdList" value="#{stdController.students}"

我有一个带有复选框的数据表供选择。来自db的值在datatable中显示为选中。当通过单击复选框进行新选择时,我可以从数组中读取后端中的值,但是当我取消选中复选框(以取消选择该行)时,该数组仍然包含选中的复选框信息。我希望数组在提交时只包含复选框信息(以便我可以从数据库中删除未选中的复选框)。这是密码-

<p:dataTable id="stdList"
                             value="#{stdController.students}"
                             selection="#{stdController.selectedStudents}" 
                             var="item"
                             rows="10"
                             rowKey="#{item.id}"
                             >
                    <p:column selectionMode="multiple" />
                    <p:column
                        sortBy="#{item.name}" 
                        filterBy="#{item.name}"
                        filterStyle="display: none;"
                        >
                        <f:facet name="header">
                            <h:outputText value="#{prop.name}"/>
                        </f:facet>
                        <h:outputText value="#{item.name}"/>
                    </p:column>
                </p:dataTable>

我的后盾是-

public Topics[] getSelectedStudents() {
    Students[] returnStudents = new Students[getSelectedStudentsAsList().size()]; // //this gets the list from db and creates the array here.
    getSelectedStudentsAsList().toArray(returnStudents);
    return returnStudents;
}

public void setSelectedStudents(Students[] selectedStudents) {
    getSelected().setStudents(new HashSet<Topics>(Arrays.asList(selectedStudents)));
 }
公共主题[]getSelectedStudents(){
Students[]returnStudents=新学生[getSelectedStudentsAsList().size()];///这将从db获取列表并在此处创建数组。
getSelectedStudentsAsList().toArray(返回学生);
返回学生;
}
公立学校选择的学生(学生[]选择的学生){
getSelected().setStudents(新的HashSet(Arrays.asList(selectedStudents));
}
非常感谢您的帮助。
TIA.

JQuery中有一个bug,它会影响PrimeFaces,但仍未修复。 选中此项:
您可以使用字符串作为行标识符作为解决方法(例如item.name)。

我忘了提到,我在JSF2.0中使用了PF RC1