Page 1 of 1

Dynamic widget creation

Posted: 05 Sep 2011, 16:37
by leenex
I need to create all UI components programmatically, and was doing great until I stumbled of the root of the Tree.
Here is the code:


UIViewRoot viewRoot = facesContext.getViewRoot();
UIComponent form1 = viewRoot.findComponent("form1");

Layout layout = new Layout();

layout.setStyle("height:530px; overflow:auto; ");
this.getChildren().add(layout);
LayoutUnit lu = new LayoutUnit();

layout.getChildren().add(lu);
treePanel = new Panel();
treePanel.setHeader("Admissions");

lu.getChildren().add(treePanel);
tree = new Tree();

treePanel.getChildren().add(tree);

DefaultTreeNode node= new DefaultTreeNode("Test", null);
node.addChild(new DefaultTreeNode("Test", root));

tree.setValue(node);


What can I do?

Re: Dynamic widget creation

Posted: 05 Sep 2011, 16:41
by Oleg
What is your problem exactly with
the root of the Tree
?

Re: Dynamic widget creation

Posted: 05 Sep 2011, 18:20
by leenex
I get an exception. I have looked into the Tree, TreeNode code, but I am quite new to JSF/Primefaces so I can't figure it out.
What I would like to do, is add a type of nodes that are capable of displaying themselves.
So, *not* this:
<p:tree value="#{...}" expanded="false" ...>
<p:treeNode type="level0">
<h:outputText value="#{item.courseRevision.tblCourseCategory.name}">
</h:outputText>
</p:treeNode>
...

Instead, I would like to add nodes like Buttons, Labels, etc. to the tree from the server side.

So, I guess it was not the root that I stumbled over, but the nodes ...

Re: Dynamic widget creation

Posted: 06 Sep 2011, 08:04
by leenex
leenex wrote:I get an exception. I have looked into the Tree, TreeNode code, but I am quite new to JSF/Primefaces so I can't figure it out.
What I would like to do, is add a type of nodes that are capable of displaying themselves.
So, *not* this:
<p:tree value="#{...}" expanded="false" ...>
<p:treeNode type="level0">
<h:outputText value="#{item.courseRevision.tblCourseCategory.name}">
</h:outputText>
</p:treeNode>
...

Instead, I would like to add nodes like Buttons, Labels, etc. to the tree from the server side.

So, I guess it was not the root that I stumbled over, but the nodes ...
I think I may have figured it out: I must create a custom renderer ...?

Re: Dynamic widget creation

Posted: 27 Sep 2011, 20:53
by prabakar_v
Dear Leenex,

I have a similar need. Can you share any code (with the custom renderer) you have written for this ?

ADV thanx ANCE,

;-p r a b u!