Reputation: 65
I am using PF 3.1.1, JSF 2.0.
I have a datatable with a column for selectBooleanCheckBox. When the user selects the row I want the checkbox to be checked and when user checks the checkbox the row should be selected.
I am making a ajax call on selectBooleanCheckBox, it updates the selectionArray in backing bean but the results are not shown on screen.
Here is the code -
<p:dataTable id="mylist" value="#{myController.selectedLists}"
selection="#{myController.myArray}"
selectionMode="multiple"
var="item"
rows="5"
rowKey="#{item.id}"
sortBy="#{item.name}"
sortOrder="ascending"
>
<p:ajax event="rowSelect"
listener="#{myController.onSelectList}"
update="mylist"/>
<p:column style="width: 20px;" id="gs">
<h:selectBooleanCheckbox id="booId"
value="#{item.booVal}">
<f:ajax execute="@this"
listener="#{myController.booValListener}"
render="mylist"/>
<f:attribute name="item" value="#{item}" />
</h:selectBooleanCheckbox>
</p:column> </p:datatable>
Any help is greatly appreciated.
Upvotes: 1
Views: 5030
Reputation: 3904
Does the checkbox/radiobutton selection method not work for you? Check out the showcase demo for that feature: http://www.primefaces.org/showcase-labs/ui/datatableRowSelectionRadioCheckbox.jsf
Now to your problem: In the past I've had problems updating a datatable after an ajax request. Unless they've addressed this since primefaces 3.0, it is not possible to update the datatable directly, you have to wrap a panelGroup around it and update the panelGroup. For example:
<h:panelGroup id="panel">
<p:dataTable id="mylist" value="#{myController.selectedLists}"
selection="#{myController.myArray}"
selectionMode="multiple"
var="item"
rows="5"
rowKey="#{item.id}"
sortBy="#{item.name}"
sortOrder="ascending"
>
<p:ajax event="rowSelect"
listener="#{myController.onSelectList}"
update="panel"/>
...
</p:dataTable>
</h:panelGroup>
Try that and see how it goes.
Upvotes: 1