Adding the component to JSF components tree at run-time

Top  Previous  Next

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

 

1.Create helper class like :

 

public class AddToolbar extends AddComponent {

       protected UIComponent getInstance() {

               Toolbar toolbar = new Toolbar();

               toolbar.setDataModel(new ToolBarDataModelBean());

               toolbar.setSelectionModel(new ToolBarSelectionModelBean());

 

               toolbar.setHeight("350");

               toolbar.setWidth("200");

 

               return toolbar;

       }

       protected String getComponentID() {

               return "toolbar1";

       }

}

 

2.Define the following construction in JSP:

 

<h:form id="form1">

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

               <f:actionListener type="testingapplication.toolbar.AddToolbar"/>

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