Possible to use SelectOneListbox to refresh PickList data?
acefrehley Apr 15, 2009 4:08 PMHi. I am trying to do the reverse of the what the picklist example does on the livedemo site. I want to make a selection on a selectonelistbox and have a picklist (left and right sides of it) change it's data on the UI everytime I make a selection.
I have tried many variations with no luck. Do I need an a4j tag on the picklist to be able to refresh (reRender) it on the UI or something?? Tags and relevant code below. I just included the code snippets that load the lists instead of the entire valuechangelistener method body.
Thank you for your time.
Tags:
<div id="ApplicationRolePickListSection" class="ApplicationRolePickListSection"> <p>Please choose an application for this user and assign user roles</p> <h:panelGrid styleClass="ApplicationRolePickListGrid" columns="2" xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.ajax4jsf.org/rich"> <h:outputText styleClass="ApplicationRolePickListHeadings" value="Choose Application"/> <h:outputText styleClass="ApplicationRolePickListHeadings" value="Assign Roles"/> <h:selectOneListbox id="applicationSelectionList" styleClass="ApplicationSelectionList" value="#{applicationRoleManager.selectedApplication}" size="8" onchange="submit()" valueChangeListener="#applicationRoleManager.loadRoleComponentsForApplicationSelection}" xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.ajax4jsf.org/rich"> <f:selectItems id="applicationList" value="#{applicationRoleManager.applications}"/> </h:selectOneListbox> <rich:pickList id="rolePicklist" styleClass="RolePicklist" value="#{applicationRoleManager.assignedRoles}" xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.ajax4jsf.org/rich"> <f:selectItems id="assignedRoles" value="#{applicationRoleManager.availableRoles}"/> </rich:pickList> </h:panelGrid> </div>
Code:
@Out(required=false) private List<SelectItem> availableRoles; @Out(required=false) private List<String> assignedRoles; ... for(SsoRole ssoRole:applicationRoleList) { availableRoles.add(new SelectItem(ssoRole.getRoleId().toString(), ssoRole.getName())); } ... for(SsoRole ssoRole:userRoleList) { logger.debug("*** LOADING ASSIGNED ROLE ID " + ssoRole.getRoleId().toString()); assignedRoles.add(new String(ssoRole.getRoleId().toString())); } ...