Dynamic widget creation

UI Components for JSF
Post Reply
leenex
Posts: 3
Joined: 05 Sep 2011, 16:31

05 Sep 2011, 16:37

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?

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

05 Sep 2011, 16:41

What is your problem exactly with
the root of the Tree
?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

leenex
Posts: 3
Joined: 05 Sep 2011, 16:31

05 Sep 2011, 18:20

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 ...

leenex
Posts: 3
Joined: 05 Sep 2011, 16:31

06 Sep 2011, 08:04

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 ...?

prabakar_v
Posts: 11
Joined: 05 Aug 2011, 12:36

27 Sep 2011, 20:53

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!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 31 guests