• Post Reply Bookmark Topic Watch Topic
  • New Topic

iterate in jsf  RSS feed

 
prash sape
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have to display the following fields in a tabular form as below

column1 | column2 | column3 | column4
[Text] [dropdown] [dropdown] [dropdown]
[Text] [dropdown] [dropdown] [dropdown]
[Text] [dropdown] [dropdown] [dropdown]
[Text] [dropdown] [dropdown] [dropdown]
...

In the backing bean, I have a List<SelectList> to cater to these dropdowns.
All these dropdowns have the same set of values.

I need a mechanism to iterate over a list in jsf.

I tried <h:datatable> and <c:foreach> but was getting error.


Error in logs
Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectOne(selectIsRetrieved)
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF pages are declarative constructs, so it's bad practice to even try and put logic on them - as you can see, often it doesn't work at all.

Your second approach (nested JSF constructs) is correct, but your problem is in the model. Ideally, you could use your backend data as the page model, but in certain cases, that won't work and you need JSF-specific constructs. In your case, what that means is that the child lists for your table model must be lists (or arrays) of SelectItems, and not the actual data items themselves.

The error message you got is confusing and I've whined to someone from Sun about it, but I don't carry much clout with them, alas.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!