Populating one listshuttle from another
mindlayr Jul 1, 2009 4:23 PMI have an application where I need to select an item in a listshuttle and have that populate the selected items in another listshuttle. I can get the initial list to populate the shuttle lists but when I select an item from the first list I can only get it to fire the <a4j:support action method when I set it to immediate. I don't know if this is the problem or not but when I look at the event object that gets passed to the method and use the .findComponent("xxx") method it gives me an object that contains the value I need but does not allow access to it.
How can I capture the selected items list in my action method so that I can use it to populate the lists that are used to re-render the listshuttle component.
I defined the .jsp like this:
<t:panelGrid id="SupplierDistLists" columns="1" columnClasses="TextNormal" rendered="true">
<rich:listShuttle
id="TargetedDistributionListDualSelect" rendered="true"
copyAllControlClass="" copyAllControlLabel="select all >>"
copyControlClass="" copyControlLabel="select >>"
removeAllControlClass="" removeAllControlLabel="<< remove all"
removeControlClass="" removeControlLabel="<< remove"
sourceValue="#{Job_Backing.availableSDL}" sourceCaptionLabel="#{l.available_supplier_distribution_lists}" sourceListWidth="300"
targetValue="#{Job_Backing.selectedSDL}" targetCaptionLabel="#{l.selected_supplier_distribution_lists}" targetListWidth="300"
style="true"
orderControlsVisible="false"
controlsType="button" var="dlItems"
>
<rich:column>
<h:outputText value="#{dlItems}"></h:outputText>
</rich:column>
<a4j:support event="onclick" actionListener="#{Job_Backing.updateDistLists}" id="ListSupport" data="dlItems" reRender="SupplierDualSelect" immediate="true"/>
</rich:listShuttle>
</t:panelGrid>
<t:panelGrid id="Suppliers" columns="1" columnClasses="TextNormal">
<rich:listShuttle
id="SupplierDualSelect"
var="items" rendered="true"
copyAllControlClass="" copyAllControlLabel="select all >>"
copyControlClass="" copyControlLabel="select >>"
removeAllControlClass="" removeAllControlLabel="<< remove all"
removeControlClass="" removeControlLabel="<< remove"
sourceValue="#{Job_Backing.availableSFL}"sourceCaptionLabel="#{Job_Backing.availableSuppliersText}" sourceListWidth="300"
targetValue="#{Job_Backing.selectedSFL}" targetCaptionLabel="#{Job_Backing.selectedSuppliersText} " targetListWidth="300"
style="true"
orderControlsVisible="false"
>
<a4j:support action="#{Job_Backing.updateSupplierFirms}" event="onclick" reRender="SupplierDualSelect, SupplierDistLists, JobCompensation, JobSalary, JobRateSelector" />
<rich:column>
<h:outputText value="#{items}"></h:outputText>
</rich:column>
</rich:listShuttle>
</t:panelGrid>
The backing method gets called and passes the ActionEvent from which I can get the UIListShuttle object and .getSubmittedValue() returns an object that has no accessors for the active item.
public void updateDistLists(ActionEvent event)
{
UIListShuttle object = ((UIListShuttle)event.getComponent().getParent().findComponent("TargetedDistributionListDualSelect"));
}
I'm guessing that since it is in immediate mode it doesn't populate the active items list but that is pure speculation on my part.
If I can get the selected items list I can update the lists and rerender with the correct values. How do I get that list?