| Author |
richface tree example
|
anitha meena
Ranch Hand
Joined: Oct 22, 2007
Posts: 40
|
|
Hi ,
I need to populate some data from databases in the form of richfaces tree in my jsf page , i have tried to follow steps in some sites but i did not successed in that , so can any one provide a simple example for this.
|
 |
Matt Kohanek
Village Idiot
Ranch Hand
Joined: Apr 04, 2009
Posts: 483
|
|
I have been at this same type of thing for three weeks now. You have some work ahead of you to be sure.
The best reources I have found for this are :
http://livedemo.exadel.com/richfaces-demo/richfaces/treeNodesAdaptor.jsf?c=treeNodesAdaptor&tab=usage
and
http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html/rich_tree.html
and to get a couple of examples of the rich tree (although not exactly simpel examples...):
http://anonsvn.jboss.org/repos/richfaces/branches/community/3.3.X/samples/
that is just a bunch of sample code, there are two tree samples close to the bottom (alphabetical order)
I can tell you that you are going to need to write java code that will take the vales out of your database and then store them in some form useable by the rich tree. I have my values stored in a java list which I then bind to rich:recursiveTreeNodeAdaptor. That gives me a tree with everything in the list, but doesnt really sort things. Currently Im working on using an xml file as the data source, but it is slow going.
If you give some sample code and where you are having issues I might be able to steer you in the right direction too
Oh and of course the richfaces forum is another great resource, usually takes about a day to get a response, but it is usually from nbelaevski, one of the people responsible for the richfaces library:
http://www.jboss.org/index.html?module=bb&op=viewforum&f=261
my username is meghiddo on those forums, so if you search for some of my posts you will see quite a few problems that I have overcome with the rich tree that might help you somewhere along the line...good luck
|
True wisdom is in knowing you know nothing - Socrates
|
 |
anitha meena
Ranch Hand
Joined: Oct 22, 2007
Posts: 40
|
|
Hi thanks alot for the reply ,and thanks for the links
I have successed to populate data from database into rich tree using the following
but the problem is that nodeSelectListener is not invoked at all which is going to display the selected node
I want to display the selectednode because my next task will be to add new node to the current selected node in the tree .
|
 |
Matt Kohanek
Village Idiot
Ranch Hand
Joined: Apr 04, 2009
Posts: 483
|
|
this may be helpful:
http://livedemo.exadel.com/richfaces-demo/richfaces/tree.jsf?tab=model&cid=1681429
|
 |
anitha meena
Ranch Hand
Joined: Oct 22, 2007
Posts: 40
|
|
Hi thanks for the reply ,
I have tried to follow the last link which you have mentioned , but the control does not go to loadTree() method , so I am not able to get any result just plain rich panel , without any error ,
I am still keeping trying ,reply me if there is any comment
|
 |
Matt Kohanek
Village Idiot
Ranch Hand
Joined: Apr 04, 2009
Posts: 483
|
|
try this to get there:
http://livedemo.exadel.com/richfaces-demo/index.jsp
then click on the rich trees menu item on the left, then click Tree from the sub menu that comes up.
Then youll have some tabs to choose from, go to default tree model.
All that it is is an example showing how you can create an h utputText whose value will be whatever node you click on with your mouse
|
 |
anitha meena
Ranch Hand
Joined: Oct 22, 2007
Posts: 40
|
|
Hi thanks a lot for the detailed reply ,
I have searched for it in all the three tree examples (recursive tree adaptor,tree , tree adaptor) but unfortunately i did not find such example....
thanks a lot for being passionate for a beginner like me.
|
 |
Matt Kohanek
Village Idiot
Ranch Hand
Joined: Apr 04, 2009
Posts: 483
|
|
Its under the second one, "tree"
After you go to that you will see some tabs along the top of the page
usage | default tree model | tree with drag and drop support | tag information
You want to go to default tree model.
It will have a tree with three roots (Daniel Defo, Edgar Allen Poe, and Henry Wadsworth Longfellow)
To the right of that tree you will see something that says Selected Node: Which will display whatever node you click on. (Selected Node: Daniel Defo) etc
Like I said though, Im not even sure if this is what you are needing.
But if it is, you can see the source for the java code and the html by clicking on the view source links towards the bottom
|
 |
Matt Kohanek
Village Idiot
Ranch Hand
Joined: Apr 04, 2009
Posts: 483
|
|
Here is the code for it anyay:
|
 |
Julia Flex
Greenhorn
Joined: Oct 15, 2009
Posts: 1
|
|
Hi! I try to run this example and i get an exception
Do you have any suggestions why could it be?
|
 |
Ron Smits nl
Greenhorn
Joined: Nov 14, 2009
Posts: 2
|
|
Julia Flex wrote:Hi! I try to run this example and i get an exception
Do you have any suggestions why could it be?
you need to include import org.richfaces.model.TreeNode;
|
 |
Alessandro Dionisi
Greenhorn
Joined: Mar 31, 2010
Posts: 3
|
|
|
I have the same problem and I don't understand which type of error can be!
|
 |
Alessandro Dionisi
Greenhorn
Joined: Mar 31, 2010
Posts: 3
|
|
|
Ok solved. I used a wrong type in value binding.
|
 |
Veerakumar yenamadala
Greenhorn
Joined: May 12, 2010
Posts: 1
|
|
Hi , i am new to this site....
Actually i am looking for a Dashboard for my application, the dashboard should be link a Tree structure in which data will be populated automatically while expanding the tree, Can any one uide me how can do this in JSF/Richfaces
|
 |
daksha sahu
Greenhorn
Joined: Dec 07, 2012
Posts: 1
|
|
I have to populate my rich:tree from DB where I store them in the following structure->
id parentid name depth lineage
1 null root 0 /1/
2 1 A 1 /1/2/
3 1 B 1 /1/3
I have gotten the data into an ArrayList. Being a complete newbie to richfaces I have no idea how to use the information to build the rich tree and even after surfing about 100 sites I have no idea what to do. Any help would do..It's really really urgent. Please Help!!
Moreover I need the tree to support functionalites for an Upload site. On automatically Uploading a File or Removing, it should display the new tree.
Following is the extent to which I have proceeded.
FolderTree.java
public class FolderTree{
int id;
int parentId;
String name;
int depth;
String lineage;
public int getid()
{
return(this.id);
}
public int getparentId()
{
return(this.parentId);
}
public String getname()
{
return(this.name);
}
public int getdepth()
{
return(this.depth);
}
public String getlineage()
{
return(this.lineage);
}
public void setid(int id)
{
this.id=id;
}
public void setparentId(int parentId)
{
this.parentId=parentId;
}
public void setname(String name)
{
this.name=name;
}
public void setdepth(int depth)
{
this.depth=depth;
}
public void setlineage(String lineage)
{
this.lineage=lineage;
}
}
StructureExtractor
import java.sql.*;
import java.util.ArrayList;
public class StructureExtractor {
ArrayList<FolderTree> tree = new ArrayList<FolderTree>();
public void extract() {
System.out.println("Getting All Rows from a table!");
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "vcms";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "sanjukta";
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db, user, pass);
try{
Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT * FROM foldertree");
System.out.println("id " + "\t" + "parentId "+ "\t" +"name"+ "\t" +"depth"+ "\t" +"lineage");
while (res.next()) {
FolderTree node = new FolderTree();
node.setid(res.getInt("id"));
node.setparentId(res.getInt("parentId"));
node.setname(res.getString("name"));
node.setdepth(res.getInt("depth"));
node.setlineage(res.getString("lineage"));
tree.add(node);
}
con.close();
}
catch (SQLException s){
System.out.println("SQL code does not execute.");
}
}
catch (Exception e){
e.printStackTrace();
}
}
}
|
 |
 |
|
|
subject: richface tree example
|
|
|