On 11/25/05, Laurie Harper <[EMAIL PROTECTED]> wrote: > > I've hit another snag trying to test out JSF with the struts-faces > integration library. This is the fragment I'm trying to convert: > > <html:select property="status"> > <c:forEach var="s" items="${project.statusList}"> > <html:option value="${s}"> > <bean:message key="status.label.${s}"/> > </html:option> > </c:forEach> > </html:select> > > And this is what I'm trying to convert it into: > > <h:selectOneMenu id="status" value="#{ProjectEdit.status}"> > <c:forEach var="s" items="#{projects.statusList}"> > <f:selectItem itemValue="#{s}" > itemLabel="#{msgs['status.label.'s.name]}"/> > </c:forEach> > </h:selectOneMenu> > > Where 'projects' is a managed bean I've defined in faces-config.xml. > This seems to present a couple of problems... > > Firstly, c:forEach doesn't know how to evaluate the #{} expression. I > can't use ${} instead as the 'projects' bean may not have been > referrenced/instantiated yet. I looked through the f: tags, but couldn't > see anything like a c:set equivalent that's #{} aware. How do I do this? > > Second, the itemLabel expression doesn't seem to work. Actually, on > second thoughts that might be to do with the things I was trying to do > to solve problem one, so I'll come back to this one...
There are some significant interoperability issues between JSF 1.0/1.1 and JSTL -- some of which have been addressed in JSF 1.2. But there is a more fundamental design issue here ... you're trying too hard :-). Consider this instead: <h:selectOneMenu id="status" value="#{ProjectEdit.status}"> <f:selectItems value="#{projects.statusList}"/> </h:selectOneMenu> where the getStatusList() method of your "projects" managed bean returns an array or list of SelectItem instances. There's no reason for you to have to do the iteration in the view tier. L. Craig