wood burning stoves*
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
JavaRanch » Java Forums » Java » JSF
Bookmark "SelectOne inside DataTable" Watch "SelectOne inside DataTable" New topic
Author

SelectOne inside DataTable

Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 61
Hi,

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: 16019
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Gabriel Beres
Ranch Hand

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

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


Bye


SQL Insert Script generator in java
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SelectOne inside DataTable