Dynamic widget creation
Posted: 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?
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?