This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SelectOne inside DataTable

 
Gabriel Beres
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17616
38
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gabriel Beres
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point. Thank you.
 
Paolo Biondo
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic