2 Replies Latest reply on Feb 12, 2009 3:03 AM by gizola

    rich:pickList and Converter problem

    gizola

      Hi!

      May be I discovered some bug in the Richfaces 3.3.0 GA.

      The situation is, that I query some records with Hibernate from a database wich is stored in a List object, wich is the source of the pickList (f:selectitems). I use a List for the right side (value, selected items container).

      In the faces-config.xml I configured a converter for the Library class, the converter class name is LibraryConverter.

      So everything looks perfect, until I want to submit the pickList with the selected items in it. Than I get a validation error, that: "j_id38:Validation error: Value is not valid."

      I found out, that for some reason the pickList upon submit does not find the converter class for the Library object, and therefore it does not use it while submitting. I configured the converter in the faces-config.xml in an other way, and I gived an ID for the converter, and set the converter-class, and I gave the rich:pickList this converter ID into the converter attribute, and it worked in this way. But I think it should work also the previous way I described.

      Please find below the code snipets:


      faces-config.xml:
      Converter configuration, wich did not work
       <converter>
       <converter-for-class>package.Library</converter-for-class>
       <converter-class>package.LibraryConverter</converter-class>
       </converter>
      
      Converter configuration, wich did work
       <converter>
       <converter-id>LibraryConverter</converter-id>
       <converter-class>package.LibraryConverter</converter-class>
       </converter>
      
      page.xhtml:
      rich:pickList declaration, wich did not work
      <rich:pickList value="#{beanB.selectedlibraries}">
       <f:selectItems value="#{beanB.libraries}"/>
      </rich:pickList>
      
      rich:pickList declaration, wich did work
      <rich:pickList value="#{beanB.selectedlibraries}" converter="LocationConverter">
       <f:selectItems value="#{beanB.libraries}"/>
      </rich:pickList>
      
      


      Oh, one thing. With the first version the Converter's getAsString method was called upon page rendering, but the getAsObject method was never called during submit. The getAsObject was first called only with the second version (the working version).

      So I think there is some bug with the pickList code where it validates the selected objects, and there it does not find the converter for the class.
      Or I just made some mistakes in my code. :)

      So thanks for replying.

      Regards,

      Gizola.