[英]Update Primefaces datatable Rows
I want to know how to update a PrimeFaces Datatable rows. 我想知道如何更新PrimeFaces Datatable行。 This is my datatable photo to understand me well:
这是我了解我的数据表照片:
![1]: http://i.stack.imgur.com/N1jGz.png ![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: 这是我的xhtml页面代码:
<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é,...) h:outputText
作为组件来呈现播放器的状态(Titulare,Blessé,...) editable="true"
with p:selectOneMenu
in the p:cellEditor
to render the list of available choices. p:cellEditor
中的p:cellEditor
p:selectOneMenu
与primefaces datatable editable="true"
一起呈现可用选项的列表。 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
您的testRadioGuest方法可能看起来像这样
private void testRadioGuest(){
for(Player player: listGamePlayerGuest){
System.out.println(player);
}
}
All state changing must be saved. 必须保存所有状态更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.