• Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying hashtable in jsf page

 
Praveen Raj
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

I have a method in my managed bean that gives me a hashtable as the output.
But other than arrays am not6 able to display an hastable in my datatable in jsf , is there any other tag which will be helpful.Plese do provide me the code also.
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot display a hashtable directly because a hash table has no inherent order, and this would mean that the table would potentially appear radically different every time it was displayed.

Additionally, raw collections cannot be displayed in a datatable anyway, since JSF has to maintain some context about the individual rows that render. You have to use a DataModel.

Combining the above, you need to construct a DataModel that refers to the elements in your hashtable. For best results, I recommend that you build a collection that sorts the Hashtable elements into a view-friendly order, then wrap that collection into a DataModel.

The rest is left as an exercise to the reader.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!