I am using rich:popuppanel component and having issues with populating values in picklist.
My requirement is as below.
Populate extended data table
Select a row using check box - User ID in that row will be passed to backing bean
Click assign button
Popup panel should open with a picklist containing all users and assigned users
The issue is, getAllUsers() call returns all users and left side of picklist is populated properly. But getAssignedUsers() is not called at all. So right side of pick list always empty.
XHTML code is as below.
<h:form id="audit">
...
<h:commandButton id="Assign" value="Assign"
immediate="true" action="#{userBean.getSelectedUsers}">
<f:ajax execute="@this" render="popupScript" />
</h:commandButton>
<h:panelGroup id="popupScript">
<h:outputScript rendered="#{userBean.assignClicked}">
#{rich:component('assignUser')}.show();
</h:outputScript>
</h:panelGroup>
...
</h:form>
<rich:popupPanel id="assignUser" autosized="true" resizeable="false">
<f:facet name="header">
<h:outputText value="#{msg.assignPopupHeader}">
</h:outputText>
</f:facet>
<h:form name="assign" id="assign">
<h:panelGrid cellspacing="5" id="popupGrid">
<a4j:outputPanel id="a4jPanel">
<rich:pickList value="#{userBean.assignedUsers}"
showButtonsLabel="false" sourceCaption="Available Users"
align="center" targetCaption="Assigned Users" listWidth="165px"
listHeight="100px" orderable="true" addText=">" removeText="<">
<f:selectItems value="#{userBean.allUsers}" />
</rich:pickList>
</a4j:outputPanel>
<center>
<h:panelGrid columns="2" cellspacing="3" cellpadding="4">
<a4j:commandButton id="assign" value="#{msg.userAssign}"
action="#{userBean.assignUser}"/>
<h:commandButton value="#{msg.userCancel}"
onclick="#{rich:component('assignUser')}.hide();return false">
</h:commandButton>
</h:panelGrid>
</center>
</h:form>
</rich:popupPanel>
My understanding is the issue is due to bean scope. My bean is view scoped, so the data in both left and right side panels are pre-populated when bean is initialized.
@PostConstruct
public void init() {
setAllUsers(userService.getAllUsers());
setAssignedUsers(userService.getAllAssignedUsers(userBean.getSelectedIdforAssign()));
}
I tried calling setAssignedUsers() with hardcoded id in init() itself. It works fine. What I need is a way to dynamically pass the ID and call getAssignedUsers().
Please suggest how to perform this and how to reRender the picklist when popup is opened.
Thanks!
The problem seems to be the selection of the users. Without the code of the table and the checkboxes I cannot say whether you do it right or not. ViewScope should be sufficient.
This might be wrong though. Probably your checkboxes never get evaluated. Try to change @this to @form.