I have a checkbox (h:selectBooleanCheckbox) in one column of a Tomahawk
dataTable which I am using to mark selected rows. I'm trying to use a
JSCookMenu that executes an action in a backing bean to process all the
selected rows in the table.
I know there's lots of ways to do this, but I'm fairly new to JSF and
I'm interested in learning why what I'm doing isn't working.
The rows of the table are mapped to a bean with a selected property
where I store if the bean is selected. I can click on the checkbox in
the table and see that it's setting the backing bean value. But when I
click on the menu item to process the selected rows(objects) in the
table, it resubmits the form and during the "Update Model Values" phase,
it resets all of the checkbox's backing bean values to false.
I'm wondering why it wouldn't be remembering the backing bean's state
for the checkboxes. The bean is session scope.
Here is a snippet of my page where I'm using these components:
<t:dataTable id="chidrenTable"
value="#{home.env.modelBean.childrenTable.childrenModel}" var="child"
styleClass="scrollerTable"
headerClass="fancyTableHeader"
columnClasses="oddColumn,evenColumn"
sortColumn="#{home.env.modelBean.childrenTable.sortColumn}"
sortAscending="#{home.env.modelBean.childrenTable.ascending}"
preserveDataModel="false"
preserveSort="true"
rows="3"
rowId="#{child.modelObject.name}"
rowOnClick="status=clickedRow(this.id)">
<h:column>
<f:facet name="header">
<t:commandSortHeader columnName="name" arrow="true"
immediate="false">
<h:outputText
value="#{msgs.nameColumnHeader}"/>
</t:commandSortHeader>
</f:facet>
<h:outputText
value="#{child.modelObject.name}"/>
</h:column>
<h:column>
<f:facet name="header">
<t:commandSortHeader columnName="creator" arrow="true"
immediate="false">
<h:outputText
value="#{msgs.creatorColumnHeader}"/>
</t:commandSortHeader>
</f:facet>
<h:outputText
value="#{child.modelObject.properties['creator'].string}"/>
</h:column>
<h:column>
<f:facet name="header">
<t:commandSortHeader columnName="creationTime" arrow="true"
immediate="false">
<h:outputText
value="#{msgs.creationColumnHeader}"/>
</t:commandSortHeader>
</f:facet>
<h:outputText
value="#{child.modelObject.properties['creationTime'].date.time}">
<f:convertDateTime pattern="d MMM yyyy
HH:mm:ss"/>
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText
value="#{msgs.selectColumnHeader}"/>
</f:facet>
<h:selectBooleanCheckbox id="selectCheckBox"
value="#{child.selected}"
onchange="submit()"
immediate="false"/>
</h:column>
</t:dataTable>
Thanks,
Kevin