I've had to iterate in the managed bean, and convert the strings to
selectitems. You wouldn't want to do that in the data tier anyway. Then
you'll have coupled your data tier with your ui tier. I don't believe
there are any helper methods to convert for you. I've done the
following:

        List<String> l = manager.getList();
        List<SelectItem> items = new ArrayList<SelectItem>(l.size());
        for (String s : l) {
                SelectItem si = new SelectItem(s, s);
                items.add(si);
        } 
        return items;

You can put this code in a util/helper class somewhere, so you don't
have to repeat this...

Frank Russo
Senior Developer
FX Alliance, LLC


-----Original Message-----
From: John Ruffin [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 21, 2006 1:03 PM
To: [email protected]
Subject: <newbie?> selectOneMenu


I pull a List of countries from db2 using hibernate like this:
public List getCountries() {
                return getHibernateTemplate().find("from Country"); }

In my managed bean I inject a manager and use it to call the above:
public List getCountryList(){           
                return  countryManager.getCountries() ;
        }

You proabably already see my problem... In my jsp, this doesn't work:
<h:selectOneMenu id="parentCountryList"
value="#{parentForm.selectedCountry
}" >            
    <f:selectItems value="#{parentForm.countryList}"/>
</h:selectOneMenu>

Error message: java.lang.IllegalArgumentException: Collection referenced
by UISelectItems with id parentForm:_id3 does not contain Objects of
type SelectItem

When/how do I make the country objects SelectItem(s)???
--
View this message in context:
http://www.nabble.com/%3Cnewbie-%3E-selectOneMenu-t1487788.html#a4030320
Sent from the MyFaces - Users forum at Nabble.com.




Reply via email to