4 Replies Latest reply on Dec 18, 2008 11:50 AM by captainvoid

    listShuttle lists not reloading

      Hello,

      I have a rich:listShuttle as shown below. On initial population they work fine. Depending on other actions the user takes I want to reset the source/target lists on the backing bean and re-render the listShuttle. Sounds simple but I can't get it to work--It keeps re-loading the previous list contents for source/target!

       <rich:listShuttle id="assignWidget" var="role"
       immediate="true"
       sourceValue="#{roleManager.source}"
       targetValue="#{roleManager.target}"
       sourceListWidth="300px"
       targetListWidth="300px"
       style="width:700px"
       fastOrderControlsVisible="false"
       orderControlsVisible="false"
       rowClasses="cursor"
       styleClass="cursor"
       sourceCaptionLabel="Available Roles"
       targetCaptionLabel="Roles Assigned to User">
       <rich:column>
       <h:outputText value="#{role}"/>
       </rich:column>
       <a4j:support event="onlistchanged" reRender="assignWidget" />
       <a4j:support event="onorderchanged" reRender="assignWidget" />
       </rich:listShuttle>
      


      Some Java code from roleManager:

       public void setTarget(List<String> target) {
       System.out.println("Setting target:"+target.size());
       this.target = target;
       Collections.sort(this.target);
       }
      
      ...
       // Elsewhere in code: re-set target list w/new contents
       System.out.println("FOUND TARGET: "+targetList.size());
       this.setTarget(targetList);
      
      


      Here's the weird part. The output looks like this. (source and target work the same so I'll just show target for simplicity)

      15:09:42,595 INFO [STDOUT] FOUND TARGET: 5
      15:09:42,595 INFO [STDOUT] Setting target:5
      15:10:24,033 INFO [STDOUT] FOUND TARGET: 2
      15:10:24,033 INFO [STDOUT] Setting target:2
      15:10:24,033 INFO [STDOUT] Setting target:5

      Ok, the first two lines show getting 5 target elements in the code and calling the setter passing the 5 elements. No problem. Then the user triggers a reload of the list contents, so we now find 2 elements and call the setter with 2 elements. Looks fine, but wait... what's that mysterious final call to the setter with (I presume) the original 5 elements? I didn't explicitly call it. On the screen the listShuttle widget is unchanged--stays loaded with the original source/target contents no matter what I do.

      How can I get the behaviour I want, i.e. reloading the source/target list on demand?

      Thanks,
      Greg



        • 1. Re: listShuttle lists not reloading
          joblini

          Hi, why are you adding a4j:support? Try removing it.

          <a4j:support event="onlistchanged" reRender="assignWidget" />
           <a4j:support event="onorderchanged" reRender="assignWidget" />
          


          Here is what we use, it works with no problem:

          <rich:listShuttle id="rolePickList" var="role"
          sourceValue="#{userController.grantableRoles}"
          targetValue="#{userController.selectedRoles}">
          <rich:column>
           <h:outputText value="#{role}"></h:outputText>
          </rich:column>
          </rich:listShuttle>


          Also, are you sure you want/need "immediate=true"?


          • 2. Re: listShuttle lists not reloading
            ilya_shaikovsky

            a4j:support works as it should.. You could not remove them.. But please show me the control which resets the list. It should be ajax single.

            • 3. Re: listShuttle lists not reloading

              Yep!

              ajaxSingle="true" plus a little less aggressive reRendering and the problem is no more.

              Thanks for pointing me in the right direction!
              Greg

              • 4. Re: listShuttle lists not reloading
                captainvoid

                Hi gzoller,
                what do you mean by "less aggressive reRendering"? How did you get it to work? Can you post the relevant code?
                thanks.