0 Replies Latest reply on Jan 17, 2013 1:01 PM by ichuchaw

    Rich:Picklist dynamic source and destination lists

    ichuchaw

      Hi everyone,

       

      I am trying to use a picklist in such a way where the source and destination lists can change, depending on which node in a tree is selected.

       

      Here is the code:

       

      <h:body>

              <h:panelGrid columns="1" border="1">

                  <h:form id="form">

                      <rich:tree toggleType="client" selectionType="ajax" var="val" selectionChangeListener="#{TestBean.selectionChanged}">

                          <rich:treeModelRecursiveAdaptor roots="#{TestBean.root}" nodes="#{val.value}">

                              <rich:treeNode>

                          #{val.name}

                      </rich:treeNode>

                          </rich:treeModelRecursiveAdaptor>

                      </rich:tree>

                  </h:form>

                   <a4j:outputPanel ajaxRendered="true" layout="block">

                  <h:form id="formf">

                      <rich:pickList id="list" value="#{TestBean.right}" var="oref" listHeight="200px">

                          <f:selectItems value="#{TestBean.left}" />

                           <a4j:ajax event="change" execute="@this"/>

                          <rich:column>

                              <f:facet name="header">Name</f:facet>

                          #{oref}

                      </rich:column>

                      </rich:pickList>

                  </h:form>

                  </a4j:outputPanel>

              </h:panelGrid>

          </h:body>

       

      In my testbean, when the selection change listener is fired, the selected tree node is stored. Additionally, two maps store the node as the key against a list of string. These maps will return the picklist and selectitems lists when the right and left methods are called.

       

      The problem I am having is that I am unable to add from the left list to the right. After I add from the left, the item in the right will disappear. I have confirmed the item does not get stored in the list. (On a side note, after I click the add button, I have to click somewhere else on the page to get the event to fire, any ideas how to make it fire after the item is added, without having to click somewhere else?)

       

      If I remove the whole map scheme and just return the same list for the destination list, then I am able to add to the destination.

       

      I have confirmed that the same left and right lists are returned each time a tree node is selected. I have populated the source lists with all the same values, to eliminate the problem where the current destination values are not possible values from the source list.

       

      The workaround I have at the moment is to return the same destination list each time a tree node is selected, but to load and store the values depending on the tree node selected. This appears to work, but in my mind, this should not be necessary.

       

       

      Any ideas?