4 Replies Latest reply on Mar 21, 2008 12:14 PM by Ilya Shaikovsky

    Objects in rich:comboBox

    Andersun Andersun Newbie


      I have bean Test (id, name).
      If I use 'new SelectItem(test.getId(), test.getName)' for adding items, comboBox views Ids. but not Names. If use 'SelectItem(test.getName(), test.getName)' I can't get Test id in converter
      How can I get Test id after submit??


        • 1. Re: Objects in rich:comboBox
          Andersun Andersun Newbie

          And enableManualInput attribute doesn't work

          • 2. Re: Objects in rich:comboBox
            Andrei '_' Newbie

            I have the same problem..

            I have the 'Project' instance with 'projectId' and 'description' fields, and I want that comboBox in jsp includes descriptions and after submit - Project with projectId.

            I tried to use Converter, but it didn't resolve this problem. To get the projectId in getAsObject method is necessary to return String projectId in getAsString method, but if getAsString method returns ids the comboBox on jsp shows Ids....

            In my backing:

            List projects = new ArrayList();
            projects.add(new SelectItem(project, project.getDescription()));

            Anybody knows how to do it?

            • 3. Re: Objects in rich:comboBox


              "Andrei_123" wrote:
              I have the same problem..
              Anybody knows how to do it?

              I know that is the richfaces forum but,
              I've used the tomahawk components...

              <t:selectOneMenu value="#{myBean.selectedObject}">
               <t:selectItems value="#{myBean.someListGetter}" var="v" itemLabel="#{v.label}" itemValue="#{v}"/>

              Their description is:
              An extended version of the standard UISelectItems. Populates the SelectItem collection from the
              given value automatically using the itemLabel and itemValue attributes.

              Of course I didn't try to use it in a rich:comboBox...

              • 4. Re: Objects in rich:comboBox
                Ilya Shaikovsky Master

                comboBox works only with values of selectItems.

                Normally comboBox designed to be used with suggestionValues list of Strings. SelectItems support added only for declarative definitions on the page.