File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes SelectOne inside DataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "SelectOne inside DataTable" Watch "SelectOne inside DataTable" New topic

SelectOne inside DataTable

Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 61

I have a datatable in a jsf page. At every row there is a htmlselectone component, and I need to populate these component, based on the current row. For example if i had a table which iterates on categories, i need to populate the selectone-s with some data based on category id.

How can a do that? I don't want my Category object to hold List<SelectItem> instances, because these are JSF things.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17282

If the list is the same for each row, no problem. If you want custom selectOne's for each different row, you will need custom SelectItem collections. That's a requirement of JSF architecture.

Don't confuse the dataTable's model with its backing data. There's no requirement that the data wrapped in the dataTable be the actual persistable data collection. I have occasionally resorted to fronting the elements in a persistable collection with decorator objects and used the collection of decorators in my dataTable.

An IDE is no substitute for an Intelligent Developer.
Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 61
Good point. Thank you.
Paolo Biondo

Joined: Aug 02, 2009
Posts: 10
Hello, I don't know if in jsf you can use the Expression Language Functions in this way.

If your dataTable contains some column mapped by your bean like

And your dataTable

where in a tld file

and in your jsp

But I repeat, i don't know if is this the way in jsf for don't use


SQL Insert Script generator in java
I agree. Here's the link:
subject: SelectOne inside DataTable
It's not a secret anymore!