myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <rick.reum...@gmail.com>
Subject Best way to use object properties from a List to create Select Items?
Date Thu, 08 Sep 2005 17:21:23 GMT
What's the best way in JSF/MyFaces to use a List to create a select
options list? I know the SelectItems can be built from a Map, but it
doesn't seem to support a list of objects too well.  Can I at least
set them easily looping over my collection manually?

For example in JSTL.. I can creat my options ...

<c:forEach items='${employees}' var='emp'>
    <html:option value="${emp.empID}">${emp.name}</html:option>
</c:forEach> 

Can I do this with a dataList inbetween  <h:selectOneMenu > tags?

It would be cool if the selectItems tag supported:

<f:selectItems collection="#{employees}" label="${name} value="${empID}" />

(above would loop over your collection of employees pull out Employee
and call appropriate getters - getName getEmpID )

-- 
Rick

Mime
View raw message