listShuttle lists not reloading
gzoller Dec 17, 2008 4:17 PMHello,
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