I want to know how to update a PrimeFaces Datatable rows. This is my datatable photo to understand me well:
![1]: http://i.stack.imgur.com/N1jGz.png
I want to choose for each row his respective state and then click Save States button to save these values.
This is my xhtml page code:
<p:panel header="List Of Players For: #gameMB.selectedGame.teamCompetitionByGuestTeam}">
<p:dataTable var="gam" value="#{gamePlayerMB.listGamePlayerGuest}">
<p:column headerText="Name Lastname">
<h:outputText value="#{gam.playerName}/>
</p:column>
<p:column>
<p:selectOneRadio value="#{gam.state}">
<f:selectItem itemLabel="Titulaire" itemValue="Titulaire" />
<f:selectItem itemLabel="Remplaçant" itemValue="Remplaçant" />
<f:selectItem itemLabel="Blesse" itemValue="Blesse" />
<f:selectItem itemLabel="Non retenu" itemValue="Non retenu" />
</p:selectOneRadio>
</p:column>
</p:dataTable>
<f:facet name="footer">
<p:commandButton value="Save States"
action="#{gamePlayerMB.testRadioGuest}" />
</f:facet>
</p:panel>
Thanks in advance.
h:outputText
as a component to render the Player's state (Titulare,Blessé,...) editable="true"
with p:selectOneMenu
in the p:cellEditor
to render the list of available choices. If I've understood you right, You just want to create table with edit function. For solving this trouble just pass your table and your button to form.
<h:form>
<p:dataTable var="gam" value="#{gamePlayerMB.listGamePlayerGuest}">
...
</p:dataTable>
<p:commandButton value="Save States" action="#{gamePlayerMB.testRadioGuest}" />
</h:form>
In this case on Save-button click all form will be sent to the server (with all your changing). Your testRadioGuest method may looked like this
private void testRadioGuest(){
for(Player player: listGamePlayerGuest){
System.out.println(player);
}
}
All state changing must be saved.
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.