Adding the component to JSF components tree at run-time

Top  Previous  Next

Tree component may be added to JSF components tree at runtime.

 

The below steps should be accomplished :

 

1.Create helper class like:

 

public class AddTree extends AddComponent {

       protected UIComponent getInstance() {

               Tree tree = new Tree();

               tree.setDataModel(new TreeDataModelBean());

               tree.setSelectionModel(new TreeSelectionModelBean());

               tree.addComponentListener("testingapplication.tree.MyTreeLeafSelectedListener");

               tree.addComponentListener("testingapplication.tree.MyTreeBranchSelectedListener");

               tree.setServerSideAction(true);

 

               tree.setJsVarName("dynamicallyAddedTree");

               tree.setFontStyle("oblique");

               tree.setFontFamily("Comic Sans MS");

               tree.setFrameless("true");

       

               return tree;

       }

       protected String getComponentID() {

               return "tree1";

       }

}

 

 

2.Use the following construction in JSP:

 

<h:form id="form1">

       <h:commandButton id="addComponent" value="Add Tree ">

               <f:actionListener type="testingapplication.tree.AddTree"/>

       </h:commandButton>

       <h:panelGrid id="panelgrid1" columns="1">

       </h:panelGrid>

</h:form>

 

 

See additional documentation in the chapter: Ability to add WebGalileo Faces component to JSF components tree at run-time