daksha sahu

Greenhorn
+ Follow
since Dec 07, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by daksha sahu

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();
}
}
}



10 years ago
JSF