2 Replies Latest reply on Feb 8, 2010 7:13 AM by Ahmet temiz

    a4j:commandButton doesn't render

    Ahmet temiz Novice

      hello

       

      I am trying to change info button color in AJAX way. As when I press this button it is supposed to change between red an blue.

      if it is blue it is supposed to red and vice versa.

       

      But it never renders and no change occurs.

       

      I will appreciate if you tell why

       

      here is the jsp tag and related bean:

       

      <a4j:commandButton id="infobutton" value="info"
            action="#{haritaBean1.finfo}" reRender="info_in,infobutton"
            image="./images/Info24.png" >                              
      </a4j:commandButton>

       

       

       

      public String finfo() {

       

              FacesContext context = FacesContext.getCurrentInstance();
          
              HtmlAjaxCommandButton info_button = (HtmlAjaxCommandButton) context
                      .getViewRoot().findComponent("harita:infobutton");

       

              if (info_button.getImage().contains("./images/Info24.png")) {
               
                  info_button.setImage("./images/Info-red24.png");
           
                  setInfo("1");

       

              } else if (info_button.getImage().contains("./images/Info-red24.png")) {
              
                  info_button.setImage("./images/Info24.png");
             
                  setInfo("0");
              }

       

              return null;

       

          }

       

       

      regards

        • 1. Re: a4j:commandButton doesn't render
          Ilya Shaikovsky Master
          check if the method actually called and if image properly changed in debug.
          • 2. Re: a4j:commandButton doesn't render
            Ahmet temiz Novice

            thank you

             

            java bean is called.

            to save the space in my previous message. I had cleared some control statements like:

             

                    System.out.println(" info_button.getId()     "+info_button.getId());
                    System.out.println(" info_button.getImage()  "+info_button.getImage());

             

            I checked program enters the every part of the bean.

             

            they look ok.

             

            I was wondering if I understood correctly the logic of Ajax:

            - when I pressed this button its color should change and whole page is not reloaded.

            - no submit is necessary

             

            only related part is updated (in my case --a4j:commandButton id="infobutton"--)

             

            when I reload page, it looks it has worked and necessary change taken place.

             

            there might be any expression that blocks ajax functionality ?

             

            regards