0 Replies Latest reply on Nov 14, 2008 3:38 AM by jegancareer

    listShuttle Help :: selectSelection and targetSelection Very

    jegancareer

      Hi All,

      I got struck in using Richfaces - listShuttle. I am able to get the sourceValue and targetValue in left and right components of Listshuttle and on click of copy/copyAll/remove/removeAll I can move the data to and fro But they are not getting populated in the selectSelection or targetSelection field bean respectively on click of save button.

      How to get the Moved data (targetSelection ) in bean . so that i can perform server side( insert/ update ) operations in DB.

      Here is my code for JSP page.

      <h:form id="shuttleCmd">
       <h:panelGrid columns="2">
      
       <rich:listShuttle id="shuttleTransit"
      sourceValue="#{transitCodesController.transitAvailablelist}"
      targetValue="#{transitCodesController.transitAssociatelist}"var="items" listsHeight="100" listsWidth="500"
      sourceCaptionLabel="Available Transit" targetListWidth="300"sourceListWidth="300"
      targetCaptionLabel="To associate cause"
      fastOrderControlsVisible="false" orderControlsVisible="false"showButtonLabels="false"
      converter="#{converter}"
      sourceSelection="#{transitCodesController.sourceSelect}"
      targetSelection="#{transitCodesController.targetSelect}">
      
       <rich:column width="65px">
       <f:facet name="header">
       <h:outputText value="Code" /> </f:facet>
       <h:outputText value="#{items.code}"></h:outputText>
       </rich:column>
      
       <rich:column width="250px" style="white-space: no-wrap;">
      <f:facet name="header">
      <h:outputText value="Name" />
      </f:facet>
      <h:outputText value="#{items.name}"></h:outputText>
      </rich:column>
      
       </rich:listShuttle>
       </h:panelGrid>
      
       <a4j:commandButton value="Save" styleClass="bouton"
       action="#{transitCodesController.commandBtnClicked}"/>
      
      </h:form>
      


      JAVA code is below :
      
       private List<ListTransitCodes> transitAvailablelist;
      
       private List<ListTransitCodes> transitAssociatelist;
      
       private Set<ListTransitCodes> sourceSelect;
      
       private Set<ListTransitCodes> targetSelect;
      
      
      
      
      public String commandBtnClicked() {
       log.debug("\n\ncommandBtnClicked successfully source "+getSourceSelect().size()+"\n\n Target "+getTargetSelect().size ());
      
      return null;
      }
      
      



      Here is my converter:
      public class Converter implements javax.faces.convert.Converter{
      
       public Object getAsObject(FacesContext context, UIComponent component,
       String value) {
       System.out.println("Converter::getAsObject");
       int index = value.indexOf(':');
      
       ListTransitCodes transitCodes = new ListTransitCodes();
       transitCodes.setCode(value.substring(0,index));
       transitCodes.setName(value.substring(index+1));
      
       return transitCodes;
       }
      
       public String getAsString(FacesContext context, UIComponent component,
       Object value) {
       System.out.println("Converter::getAsString");
       ListTransitCodes optionItem = (ListTransitCodes) value;
       return optionItem.getCode()+ ":" + optionItem.getName();
       }
      
      







      Any suggestion or ideas?

      Thanks
      Jegan