• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamically create JSF components  RSS feed

 
Justin Krettabull
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a selectManyListBox. I want to populate the selectItems dynamically at runtime using JSTL. My code is something like this:

<h:selectManyListbox id="manyList">
<c:forEach var="s" items="${myCollection}" >
<f:selectItem itemValue="<c ut value="${s.id}"/>" itemLabel=<c ut... />
</c:forEach>
</h:selectManyListbox>


My code is failing. Does anyone have a simple example of how to do this?
Seems like this should be really easy.

thanks,
 
Justin Krettabull
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out.

In Rational Application Developer6, click on the 'selectManyList' component in design view. Then go to properties and select 'Add set of choices'. In there, you tell it the name of the collection and the contained type, and the field(s) to display.

The code ends up looking as such:

<h:selectManyListbox id="manyList">
<f:selectItems value="#items.sessionScope.types.description.description.toArray}" />
</h:selectManyListbox>

The output is a multi-select dropdown list populated with data from a Collection in sessionScope.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!