Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SelectOne inside DataTable

 
Gabriel Beres
Ranch Hand
Posts: 61
  • 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: 18272
56
Android Eclipse IDE Linux
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point. Thank you.
 
Paolo Biondo
Greenhorn
Posts: 10
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic