0 Replies Latest reply on Jun 20, 2008 6:42 AM by Markus -

    How to add uicomponents dynamically to a4j:outputPanel?

    Markus - Newbie

      Hi,

      i have a outputPanel and i want to add uicomponents dynamically to it:

      <a4j:outputPanel id="pgroup">
      </a4j:outputPanel>
      
      <webuijsf:button text="test" actionListenerExpression="#{testBean.select}"/>
      <a4j:commandButton value="test2" actionListener="#{testBean.select}"/>
      


      My server bean code looks like this:
      FacesContext ctx = FacesContext.getCurrentInstance();
      UIComponent c = ctx.getViewRoot().findComponent("form1:pgroup");
      if (c != null)
      {
       com.sun.webui.jsf.component.Button b1 = new Button();
       b1.setText("ab111");
       c.getChildren().add(b1);
      
       com.sun.webui.jsf.component.Button b2 = new Button();
       b2.setText("ab222");
       c.getChildren().add(b2);
      }
      


      When i click the "webuijsf:button" it works. But when i click the "a4j:commandButton" it doesn't work. The buttons are not shown. I know that richfaces-ajax must known the ids. But how i can say to richfaces that i have added dynamic components on server side. There are a lot of use cases where dynamic tables, lists or oder things are needed which are not known at design-time. How richfaces supports this request.

      Thanks in advance.

      cu
      Markus