Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSF and the fly likes <rich:tree> and database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "<rich:tree> and database" Watch "<rich:tree> and database" New topic
Author

<rich:tree> and database

Mladen Stupar
Greenhorn

Joined: Oct 14, 2009
Posts: 3
Is it possible to fill the <rich:tree> component nodes, with data from the database?

I have a table "Categories" in the database with two columns: "id_category" and "name_category". In treeBean class I have a method:
Below this I have "get" and "set" methods.

My JSF code for <rich:tree> component looks like this:
But this, in this way doesn't work. I get the following error message:
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16908
    
  26

You can. I do. However, you can't simply point the tree at the data, you need a treemodel wrapper just like you need a databtable model wrapper. They both help maintain the UI-specific context.

Check the RichFaces docs. In recent releases, they added a way to easily wrap things such as domain model objects so you don't actually need to construct a tree-specific data model.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: <rich:tree> and database
 
It's not a secret anymore!