PrimeFacesデータテーブルを使用してWebアプリケーションを開発しようとしています。選択した行に対応するオブジェクトを取得するのが難しいです。私がそれを行うたびに、ヌル値が選択されます。ここに関連するコードは次のとおりです。RadioButtonsを使用してPrimeFacesでテーブル行を選択できません
<p:dataTable id="presTable" var="pres" value="#{presBean.presentations}"
rows="10" scrollable="true" scrollWidth="85%"
selection="#{presBean.selectedPres}" rowKey="#{pres.id}" paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,25,100" widgetVar="presTable" filteredValue="#{presBean.filteredPres}" selectionMode="single">
</p:column>
<f:facet name="footer">
<p:commandButton id="updateButton" process="presTable" value="Update" action="#{presBean.printSelectedPres()}"/>
</f:facet>
</p:dataTable>
のJavaバッキングBean:
public Presentation getSelectedPres() {
System.out.println("Returning selected presentation: " + selectedPres);
return selectedPres;
}
public void setSelectedPres(Presentation selectedPres) {
System.out.println("Setting selected presentation to " + selectedPres);
this.selectedPres = selectedPres;
}
public void printSelectedPres() {
System.out.println("Printing list of checked presentations:");
System.out.println(selectedPres);
}
'p:dataTable'は' h:form'で囲まれていますか? –