This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "<rich:tree> and database" Watch "<rich:tree> and database" New topic

<rich:tree> and database

Mladen Stupar

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: 15950

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.
subject: <rich:tree> and database
Similar Threads
Need my rich:tree to be re loaded when I add a new entity to it
richface tree example
Problem getting richfaces tree to display
problem JSF - datatable from DB
Trying to get layout worked out for three content panes (using facelets template)