0
私は選択のためのチェックボックスを備えたデータテーブルを持っています。 dbからの値は、データテーブルにチェックされて表示されます。チェックボックスをクリックして新しい選択を行うと、配列からバックエンドの値を読み取ることができますが、その行の選択を解除すると、その配列にはチェックされたチェックボックス情報が残っています。私は配列のチェックボックスの情報を送信時にチェックするだけです(dbからチェックされていないものを削除することができます)。ここでは、コードです -データテーブルのプライム面のチェックボックスの選択解除値を読み取る
<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>
私のバッキングBeanがある -
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)));
}
すべてのヘルプは本当に感謝しています。 TIA。
私はPF RC1とJSF 2.0を使用しています – goodprg