0 Replies Latest reply on Mar 14, 2008 6:22 PM by Paul Pantages

    ListShuttle Ignores Converted Values

    Paul Pantages Novice

      Hello Forum,

      I am trying to use a list shuttle with a covnerter.

      I have an ArrayList for both my source and target lists.
      The list items are String.
      E.g., one entry is: "specificProblem"

      I wanted to present different string values in the picklists.
      E.g., I want to show "Specific problem"

      I thought that I could define a converter to map the
      strings back and forth. Since my "objects" are also strings
      I thought this would be fairly straightforward.

      I can see from println statements that the converter is
      being called to convert the source and target lists as
      expected.

      When the page is rendered, I see calls togetAsString,
      E.g., I see:
      "getAs String from specificProblem to Specific problem"

      When it is submitted I see calls to getAsObject.
      E.g., I see:
      "getAsObject from Specific problem to specificProblem"

      However, when the shuttle is displayed, I see the original values,
      not the converted values. E.g., in this case I see
      "specificProblem" in the list, not "Specific problem" as I want.

      Am I misunderstaning something?

      The shuttle seems to discard the converted values & display "object"
      values instead.


      My Shuttle:

       <rich:listShuttle
       sourceValue="#{reportEntry.adp}"
       targetValue="#{reportEntry.dp}"
       var="items"
       sourceCaptionLabel="Available Properties"
       targetCaptionLabel="Included Properties"
       removeAllControlLabel="Remove all"
       removeControlLabel="Remove properties"
       copyControlLabel="Add properties"
       copyAllControlLabel="Add all"
       fastOrderControlsVisible="true"
       orderControlsVisible="true"
       converter="#{reportEntry.pc}">
      
       <rich:column>
       <h:outputText value="#{items}"></h:outputText>
       </rich:column>
      
       </rich:listShuttle>
      


      My converter:

       public Object getAsObject(FacesContext context, UIComponent component, String value)
       throws ConverterException {
      
       System.out.println("getAsObject from " + value + " to " + _nameMap.get( (String)value ) );
       return ( StringUtils.isEmpty(value) ) ? null : _nameMap.get( (String)value );
       }
      
       public String getAsString(FacesContext context, UIComponent component, Object value)
       throws ConverterException {
      
       if(value == null) {
       return "";
       }
       else if ( value instanceof String )
       {
       System.out.println("getAs String from " + value + " to " + nameMap.get( (String) value ) );
       return nameMap.get( (String) value );
       }
       {
       throw new ConverterException("Property Name not string value." );
       }
       }