3 Replies Latest reply on Dec 4, 2007 7:31 PM by pmuir

    How obtaining data from a select box

    haefti

      Hi!
      I'm pretty new to Seam and try to go through the book and the examples.
      No I have a problem. I wonder how I can display data from a database table in a select box which allows me to choose one element and edit this entry.
      I tried

      <h:selectOneListbox>
      

      for the select element
      and
      <s:selectItems>
      <s:convertEntity>
      

      for the data which works but as I read here several times here <s:selectItems> lacks an itemValue attribute so the value attribute of the rendered option elements can not be set to the id of the displayed data for example.
      I think this is necessary for me if I want to choose one item and use the chosen id as parameter to modify the selected element.

      Does anyone have an idea or an alternative way to display data in a select box and choose an item?

      Thanks!

      Haefti

        • 1. Re: How obtaining data from a select box
          pmuir

          Why do you need the id? Sounds like you don't to me.

          itemValue is present in CVS, as is the possibility to override the output from s:convertEntity so will be in the 2.0.1 release.

          • 2. Re: How obtaining data from a select box
            haefti

             

            "pete.muir@jboss.org" wrote:
            Why do you need the id? Sounds like you don't to me.


            Hm, but how do I get the selected element?
            To compare it to examples from the book (from Michael Yuan), is it injected just like the example with the data table?
            So if I have a list of Person objects in the select box, can I refer to the selected Person in the ManagerAction just like the way in the integration example via @DataModelSelection?

            itemValue is present in CVS, as is the possibility to override the output from s:convertEntity so will be in the 2.0.1 release.


            Due to JBoss version restriction I'm forced to use Seam 1.2 at the moment.

            Thanks!

            Haefti

            • 3. Re: How obtaining data from a select box
              pmuir

              Take a look at the ui example, it has many examples of using this. It's just like any input componet, you use a value binding to the model, and JSF takes care of updating the model for you.