Reputation: 8604
Some problematic bahaviour in my JSF2 project.
I have a dropdown box h:selectOneMenu
which trigers a refresh in a page onchange = "submit();"
which in turn causes my h:dataTable
to be populated with checkboxes h:selectBooleanCheckbox
.
The problem is that I don't get all the ValueChangeEvent
events from checkboxes - I only get as many events as there were checkboxes in the initial dropdown selection. For example:
setNodeState
events are fired. MultiFileSelectMgmtBean.fileNames
. I select all checkboxes.setNodeState
events are fired, not 10 as I would expect.Here is xhtml code:
<tr>
<td>
<h:selectOneMenu
value = "#{MultiFileSelectMgmtBean.selectedLocationId}"
valueChangeListener = "#{MultiFileSelectMgmtBean.LocationChangeEvent}"
onchange = "submit();"
styleClass = "text" style="width: 250px;">
<f:selectItems
value = "#{MultiFileSelectMgmtBean.locationsListItems}"
var = "location"
itemValue = "#{location}"
itemLabel = "#{location.label}">
</f:selectItems>
</h:selectOneMenu>
</td>
</tr>
<tr>
<td>
<h:dataTable value="#{MultiFileSelectMgmtBean.fileNames}" var="filename">
<h:column>
<h:selectBooleanCheckbox value = "#{MultiFileSelectMgmtBean.fileMap[filename]}"
valueChangeListener = "#{MultiFileSelectMgmtBean.setNodeState}"
title = "#{filename}"
/>
<h:outputText value="#{filename}" styleClass="text"/>
</h:column>
</h:dataTable>
</td>
</tr>
Upvotes: 1
Views: 1606
Reputation: 8604
Problem was the backing bean consturctor. I was always initializing the dropdown box with first selection. Then the event would change it to some other selectin.
Now I am saving the state of dropdown as a session var. When bean is created, it first checks if this state was saved, and if yes load it.
Upvotes: 1