8 Replies Latest reply on Feb 15, 2011 4:07 AM by Mudassar Hanif

    Rendered attribute on commandButton breaks action

    Tanya Ruttenberg Expert

      Here are 2 sets of buttons:


        <h:form>
          <rich:panel id="op1">


            <a4j:commandButton id="cb1" reRender="op1" rendered="#{editPageMode}"
                value="Set Edit Mode to False editPageMode: #{editPageMode}"

                actionListener="#{pageBean.setEditPageMode(false)}"  />


            <a4j:commandButton id="cb2" reRender="op1" rendered="#{not editPageMode}"
                value="Set Edit Mode to True editPageMode: #{editPageMode}"

                actionListener="#{pageBean.setEditPageMode(true)}"  />


          </rich:panel>
        </h:form>
        <h:form>
          <rich:panel id="op2">


            <a4j:commandButton id="cb3" reRender="op2"
                value="Set Edit Mode to False editPageMode: #{editPageMode}"

                actionListener="#{pageBean.setEditPageMode(false)}"  />


            <a4j:commandButton id="cb4" reRender="op2"
                value="Set Edit Mode to True editPageMode: #{editPageMode}"

                actionListener="#{pageBean.setEditPageMode(true)}"  />


          </rich:panel>
        </h:form>

       

       

      pageBean:

       

      @Name("pageBean")
      public class PageBean {
         
          @In(required=false)
          @Out(required=false)
          Boolean editPageMode;
         
          public void setEditPageMode(Boolean editPageMode) {
              System.out.println("pageBean: setting edit mode " +  editPageMode);
              this.editPageMode = editPageMode;
          }

       

      }

       

       

      All of these buttons except one work as advertised.  That is to say when you click it, the setEditPageMode(mode) method fires.  The only one that does not work is "cb1".   For the life of me I cannot figure out why it doesn't work.  It is identical to its counterpart, cb3, the only difference being the rendered tag.  But the rendered tag has no effect on cb2.  The only difference between cb1 and cb2 is that one sets editPageMode to true and one sets it to false.

       

      Can anyone see why this is not working?  This is driving me crazy.

       

      Tanya