0

I need arbitrary nested TreeTable's, so I created them programmatically by:

TreeNode r=new DefaultTreeNode("R",null), s=new DefaultTreeNode("S",r), t=new DefaultTreeNode("T",s);
s.setExpanded(true);  t.setExpanded(true);
TreeTable treeTable=new TreeTable();
treeTable.setValue(r);
treeTable.setVar("var");
Column col=new Column();
OutputLabel ol=new OutputLabel();
ol.setValue("node");  // later use valueExpression
col.getChildren().add(ol);
treeTable.getColumns().add(col);
Panel op=(Panel)FacesContext.getCurrentInstance().getViewRoot().findComponent("form:panel");
op.getChildren().add(treeTable);`

This adds a TreeTable into a Panel. However, while clicking on the arrow of the root node correctly collapses it, expanding is impossible.

Additionally, I did not find much documentation about how to programmatically create PF components, but some specialist blogs.

Tools: PF6.0, glassfish4.1.1, CDI1.1, Java 8, Mojarra 2.2.12, JEE 7

Marc Dzaebel
  • 425
  • 4
  • 12
  • Start by reading http://stackoverflow.com/questions/16610655/why-should-i-use-createcomponent-instead-of-creating-the-instance-myself – Kukeltje Sep 21 '16 at 21:33
  • Good hint, however, polymorphic creation doesn't change the expand problem. Also, I know, that creating UIComponents programmatically usually isn't necessary or recommended. However, I currently don't see an easy method (but custom components) to achieve arbitrary nested components with markup, while the depth is not known. May be this usecase should be considered for next JSF versions. – Marc Dzaebel Sep 22 '16 at 17:04

0 Answers0