2 Replies Latest reply on Nov 7, 2008 6:51 PM by Hoang Nguyen

    a4j:actionparam in java

    Hoang Nguyen Newbie

      hello,
      i have tried to create a4j:commandButton and a4j:actionparam in java. For example i use ActionParameter Demo

      <a4j:commandButton value="Set Name to Alex" reRender="rep" >
       <a4j:actionparam name="username" value="Alex" assignTo="#{userBean.name}"/>
      </a4j:commandButton>
      


      hier is my code

      HtmlAjaxCommandButton() button = new HtmlAjaxCommandButton();
      button.setTitle("Set Name to Alex");
      
      HtmlActionParameter actionParameter = new HtmlActionParameter();
      actionParameter.setName("username");
      actionParameter.setValue("John");
      button.getChildren().add(actionParameter);
      


      but i don't know how can i define reRender="rep" and assignTo="#{userBean.name}"

      has someone idee?
      thanks in advance

        • 1. Re: a4j:actionparam in java
          Ilya Shaikovsky Master

          setRerender method for command Button
          and setAssignToBinding for parameter (ValueExpression should be passed)

          • 2. Re: a4j:actionparam in java
            Hoang Nguyen Newbie

            hello,
            i did what you said

            button = new HtmlAjaxCommandButton();
            button.setValue("Set Name to Alex");
            button.setReRender("rep");
            
            HtmlActionParameter actionParameter = new HtmlActionParameter();
            actionParameter.setName("username");
            actionParameter.setValue("Alex");
            actionParameter.setAssignToBinding(createValueExpression("#userBean.name}", String.class)) ;
            button.getChildren().add(actionParameter);
            

            but at first, button label is not "Set Name to Alex" but org.ajax4jsf.......
            second when i click on button, this name will be not changed

            ilya_shaikovsky can you give more concrete explain please

            thanks a lot