h:selectManyCheckbox inside rich:popupPanel not performing assignments
fericit.bostan Nov 14, 2012 7:16 PMI'm attempting to use the h:selectManyCheckbox to assign a limited number of objects to a parent object. ( User -> Items) I'm able to get the popupPanel to render correctly and display the current assigned values as selected. The problem is that when I select additional items they do not get assigned to the parent object prior to the invocation of the save action.
I have a converter defined but it never gets invoked. I've also defined a valueChangeListener on the selectManyCheckbox but no values get passed in. The result is an empty array.
<rich:popupPanel id="user-items" modal="true" autosized="true" resizeable="false" zindex="1002"
styleClass="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable" moveable="true">
<f:facet name="header">
<h:outputText value="#{msg['usermgmt.label.edit.user.items']}" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#" onclick="#{rich:component('user-items')}.hide(); return false;">
X
</h:outputLink>
</f:facet>
<a4j:region id="items-edit" styleClass="region">
<h:panelGroup styleClass="region">
<h2>
<h:outputFormat id="user-items-title" value="#{msg['usermgmt.edit.user.items.title']}">
<f:param value="#{userListController.selectedUser.name}"></f:param>
</h:outputFormat>
</h2>
<richext:spacer height="10" />
<h:panelGroup layout="block" styleClass="items">
<h:selectManyCheckbox id="user-items-checkbox" value="#{userListController.selectedItems}"
converter="#{itemsConverter}" valueChangeListener="#{userListController.processValueChange}" >
<f:selectItems value="#{userListController.items}" />
</h:selectManyCheckbox>
</h:panelGroup>
<richext:spacer height="20" />
<h:panelGroup layout="block" styleClass="actions">
<h:panelGroup layout="block" styleClass="button">
<a4j:commandButton value="#{msg['user.label.update']}" execute="@region"
onclick="saveItems(); return false;" />
</h:panelGroup>
<h:panelGroup layout="block" styleClass="button">
<a4j:commandButton value="#{msg['delete.cancel']}"
onclick="#{rich:component('user-items')}.hide(); return false;" />
</h:panelGroup>
</h:panelGroup>
</h:panelGroup>
</a4j:region>
</rich:popupPanel>
<a4j:jsFunction name="saveItems" action="#{userListController.saveItems}" render="userTable" execute="@form"
oncomplete="#{rich:component('user-items')}.hide();" />
The entire page is composed inside of a single <h:form> element, including the popupPanel.
The user is correctly assigned when the Edit Items button is selected. The backing bean is invoked and the selected user is assigned correctly.
<rich:column rendered="#{request.isUserInRole('ROLE_ADMIN')}">
<a4j:region>
<a4j:commandButton styleClass="item-button" value="#{msg['usermgmt.label.edit.items']}"
action="#{userListController.setSelectedUser(currentUser)}"
oncomplete="#{rich:component('user-items')}.show();"
render="user-items-title user=item-checkbox" />
</a4j:region>
</rich:column>
My backing bean has the following defined:
@ManagedBean
@ViewScoped
public class UserListController implements Serializable, ValueChangeListener {
private User selectedUser;
private List<Market> selectedItems;
private List<SelectItem> items;
@PostConstruct
private void postConstruct() {
items = new ArrayList<SelectItem>();
for (Item item : getItemService().findAll()) {
items.add(new SelectItem(item, item.getName()));
}
}
So what am I missing? Why isn't my itemConverter invoked and the assignment performed? I've spent a good amount of time trying to figure this out to no avail, so any help you can provide is greatly appreciated.
Thanks in advance...