-
1. Re: Drag & Drop between dataTable and Tree
nbelaevski Mar 24, 2010 7:41 AM (in response to jsfgeeks)Hi,
You are using rich:dataTable as source, so draggableSource cannot be UITreeNode.
-
2. Re: Drag & Drop between dataTable and Tree
jsfgeeks Mar 26, 2010 1:41 AM (in response to nbelaevski)Thanks for your support.
Now I am creating a tree dynamically. (<rich:tree> is defined in my jsp page and I am adding nodes from backbean on create button and removing on Remove button). Now, what I want is, can I have a full tree structure (with ID and values) on one button click, say Save Tree, so that on the save button, I can store it in DB. (different node level in different tables).
I hope my question is clear.
Thanks again,
JSF GEEKS
-
3. Re: Drag & Drop between dataTable and Tree
nbelaevski Mar 26, 2010 7:06 AM (in response to jsfgeeks)You already have tree structure, so you can walk through it and store nodes in DB. Or am I not getting the problem?
-
4. Re: Drag & Drop between dataTable and Tree
jsfgeeks Mar 26, 2010 7:22 AM (in response to nbelaevski)Hi nick,
Can you give me an example of how to walk through the tree and get the values. I am new to tree.
Thank you,
JSF GEEKS
-
5. Re: Drag & Drop between dataTable and Tree
nbelaevski Mar 26, 2010 6:18 PM (in response to jsfgeeks)There are two ways of providing data for tree component: using model (TreeNode-based classes) or declarative tags (rich:treeNodeAdaptor & its recursive version). In the first case you have to traverse the model manually (i.e. by calling getChildren()); for the second case you've built the tree from the pre-existing lists, so you can just store them then.
-
6. Re: Drag & Drop between dataTable and Tree
jsfgeeks Mar 27, 2010 12:51 AM (in response to nbelaevski)Thanks nick,
But as I mentioned earlier, I am new to tree. So, can you provide any simple example or a link to the example of it, so that I can understand easily. The function, which I am using to add nodes is as below,
public String addNode()
{
try
{
//System.out.println("\n\t Adding Node...");
outtxt_msg.setValue(null);
outtxt_msg.setRendered(false);
TreeNodeImpl nodeImpl = new TreeNodeImpl();
if (txtTopic == null || txtTopic.length() <= 0) // txtTopic is a variable, which has a value of inputText
{
//System.out.println("\n\t Enter node name to create...");
outtxt_msg.setValue("Enter node name to create.");
outtxt_msg.setRendered(true);
return null;
}
nodeImpl.setData(txtTopic);
if (selectedNode == null)
{
selectedNode = rootNode;
}
selectedNode.addChild(new Integer(index), nodeImpl);
index++;
txtTopic = "";
}
catch (Exception e)
{
System.out.println("\n\t Error rin adding node...\n\t\t " + e);
}
return null;
}And I am using drag N drop functionality, by using two trees. So can you help some more ?
Thank you,
JSF GEEKS
-
7. Re: Drag & Drop between dataTable and Tree
nbelaevski Mar 28, 2010 4:17 PM (in response to jsfgeeks)1 of 1 people found this helpfulHmm, I'm not sure what exactly example is necessary, but I'll try:
public class TreeBean<T> { TreeNode<T> rootNode; public void saveRoot() { Iterator<Map.Entry<Object, TreeNode<T>>> children = rootNode.getChildren(); while (children.hasNext()) { Entry<Object, TreeNode<T>> entry = children.next(); TreeNode<T> childNode = entry.getValue(); //add data from "childNode" to be saved in DB //... saveChildNode(childNode); } } private void saveChildNode(TreeNode<T> childNode) { // TODO Auto-generated method stub } }
-
8. Re: Drag & Drop between dataTable and Tree
jsfgeeks Mar 29, 2010 12:35 AM (in response to nbelaevski)Thanks Nick for the great help. It works fine.
But, as I told you, I have a dynamic tree creation. so, user can go up to any level. The two functions, which you have suggested, works fine but it's for static (two level) trees only. So if I want to generate a function which can get data from tree of any level, then it will be great for me.
Thanks again,
JSF GEEKS
-
9. Re: Drag & Drop between dataTable and Tree
nbelaevski Mar 29, 2010 6:23 AM (in response to jsfgeeks)Then you just call this method recursively passing the name of the table according to the level.
-
10. Re: Drag & Drop between dataTable and Tree
jsfgeeks Mar 30, 2010 3:59 AM (in response to nbelaevski)Thanks Nick,
I have tried the recursive function. Now, what I want is, if the tree node is leaf, then after inserting all the leaf of particular node(parent), then I want to remove that (parent)node from the tree. And for that, I need a row key. So, by using that TreeNode object, how can I remove that (parent)node.
How can I get the rowkey of particular TreeNode ?
Thanks for great support,
JSF GEEKS
-
11. Re: Drag & Drop between dataTable and Tree
jsfgeeks Mar 31, 2010 6:24 AM (in response to jsfgeeks)Hi Nick,
Finally I got the solution by using 2 recursion functions.
Anyway, thanks for your support.
JSF GEEKS