1 Reply Latest reply on Jul 21, 2010 7:48 AM by Serkan Eskici

    Dynamically adding UIComponents in JSF

    Neerou b Newbie

      Hello everyone!,

      I needed advice regarding adding components dynamically on a page.

      I have to add HtmlInput Text on a form on clicking an Add button.

      The text controls should be added dynamically.

      I have tried the following codes but could not render the text boxes.

      <h:form id="myForm2">
                     <h:panelGrid id="test" binding="#{parrainage.htmlPanelGrid}">
                          <h:inputText value="#{parrainage.email}" />
                     <s:button action="#{parrainage.addControlForEmail}" value="Ajouter2"></s:button>

      private HtmlPanelGrid htmlPanelGrid;
      //getters and setters

      public String addControlForEmail() {
                UIColumn col = new UIColumn();
                HtmlOutputText ot = new HtmlOutputText();
                HtmlInputText it = new HtmlInputText();
                if (htmlPanelGrid == null) {
                     htmlPanelGrid = new HtmlPanelGrid();
                return "someaction psgr";

      Though the hmtlPanelGrid is binded, when the Ajouter2 button is clicked the htmlPanelGRid property is null.

      Ccan anyone advise what is wrong, please