2 Replies Latest reply on Sep 30, 2011 6:10 PM by RayDeCampo

    How to add ajax functionality to a dynamically created component?

      Using JSF 2.0.

      I have a need to generate components in my backing beans and have them displayed on the page when rendered.
      Creating the component is not an issue, I can do that with the code listed below.
      However I want to add ajax functionality and I do not know how to do that in the backing bean.

      A simple example of an ajax enabled component on an xhtml page would be something like:

      <h:commandButton id="buttonId" action="#{backingBean.buttonAction}" value="Push Me" >
      <f:ajax render="componentName" />

      To create something similar in a backing bean I use the following code in my backing bean:

      button = new HtmlCommandButton();
      button.setId( "buttonId" );
      button.setType( "submit" );
      button.setTitle( "Push this button to....");
      button.setValue( "Push Me" );

      I then add this as a child of a component on the page.

      What I don't know how do do is add the ajax behavior to this compponent.

      Does anyone know how to do this?