1 Reply Latest reply on Aug 31, 2009 9:41 PM by oneworld95

    Data access in Seam for dropdown box

    oneworld95

      Hi. I've got a simple app that uses the Generate Seam Entities to reverse-engineer a table. The table holds values for a dropdown box. Eclipse and Seam have generated the entity classes, and the auto-generated XHTML pages work fine. What I need is to use the data pulled from the table to populate a dropdown box, as a very simple example to get me started using Hibernate and Seam data access.


      I tried adding an h:selectOneMenu to the Table1List.xhtml page, but the ArrayList needs to first be converted to SelectItem elements. Generating an ArrayList of SelectItems is easy in an action class. But how do you reference the data in the backing bean? I'm looking at the XHTML, and it references the data this way:


      #{Table1List.resultList}



      Not sure how to reference this in the class file, though. Thanks.

        • 1. Re: Data access in Seam for dropdown box
          oneworld95

          Found this solution; of course, at this stage, I'm not storing the dropdown box's value anywhere. Also need to figure out how to add a null element to the first item, so users can select nothing for this non-required field.


          <h:selectOneMenu>
            <s:selectItems var="tape" value="#{Table1List.resultList}" label="#{tape.description}" />
            <s:convertEntity/>
          </h:selectOneMenu>