4 Replies Latest reply on Sep 21, 2009 8:52 AM by nimo22

    comboBox converter strange behaviour

    nimo22

      I use comboBox with seams entity converter:

      <rich:comboBox value="#{myEntity}" converter="org.jboss.seam.ui.EntityConverter">
       <s:selectItems value="#{myEntities}" var="_o" label="#{_o.name}"/>
       </rich:comboBox>


      It renders the #{_o.name} not correctly. Instead of the name, the items in comboBox contains of a list of numbers:

      157,158,159,...


      very strange!

      Using a common selectOneMenu:

      <h:selectOneMenu value="#{myEntity}">
       <s:selectItems value="#{myEntities}" var="_o" label="#{_o.name}"/>
       <s:convertEntity/>
       </h:selectOneMenu>


      all works as expected - {_o.name} contains items of names.

      So what is wrong with rich:comboBox ??

        • 1. Re: comboBox converter strange behaviour
          ilya_shaikovsky

          you should consider the fact that comboBox is just input and not a select. So it uses just value from selectItem to define suggestions but not the pair value-label.

          • 2. Re: comboBox converter strange behaviour
            nimo22

            okay, got it. but then I do not really understand the sense of converter-property - comboBox views a list of strings.

            So the suggestionValues needs a list of strings, the selectItem-value can be a object and can be related to a converter, am I right?

            Either I define no converter, and the list contains of something like this

            "myEntities.User@74976424".


            Or I define a converter, and the list contains of something like this
            157,158,159,...
            (I do not know, where the numbers come from, these numbers are not in my objects instance).

            In both cases, the represantal string is useless.

            So for what converter?


            • 3. Re: comboBox converter strange behaviour
              ilya_shaikovsky

              Again the component not uses label of the select Items. only value. And the representation you actually got - returned from the converter. Just check in debug.

              • 4. Re: comboBox converter strange behaviour
                nimo22

                 

                Again the component not uses label of the select Items. only value.


                ahh. yes, now I understand.

                the problem is the seam converter ..as it got the entity which should be converted back from the value-attribute (and in my case, the value attribute is not the entity-represantation {_p.name} instead of #{_p}).

                thank you!