1 Reply Latest reply on Apr 10, 2009 5:47 AM by ilya_shaikovsky

    AJAX reRender

    fscan

      hello,

      i would like to understand the rerender behaviour of a:commandLink.

      xhtml file:

      <div>
       <a:region>
       <h:form>
       <s:div id="testRerender1" rendered="${RerenderHome.rendered1}">
       <a:commandLink action="${RerenderHome.action1()}"
       value="rerender1"
       reRender="testRerender1" />
       </s:div>
       </h:form>
       </a:region>
      </div>
      <s:div rendered="${RerenderHome.rendered3}">
       <h:form>
       <s:div id="testRerender2" rendered="${RerenderHome.rendered2}">
       <a:commandLink action="${RerenderHome.action2()}"
       value="rerender2"
       reRender="testRerender2"/>
       </s:div>
       </h:form>
      </s:div>


      java file:

      @Name("RerenderHome")
      public class Home implements Serializable
      {
       public Boolean getRendered1()
       {
       System.err.println("rerender 1");
       return true;
       }
       public Boolean getRendered2()
       {
       System.err.println("rerender 2");
       return true;
       }
       public Boolean getRendered3()
       {
       System.err.println("rerender 3");
       return true;
       }
       public void action1()
       {
       System.err.println("action1");
       }
       public void action2()
       {
       System.err.println("action2");
       }
      }


      when i click the rerender1 link this is the output:

      15:51:17,232 ERROR [STDERR] rerender 1
      15:51:17,233 ERROR [STDERR] rerender 1
      15:51:17,234 ERROR [STDERR] rerender 1
      15:51:17,236 ERROR [STDERR] rerender 1
      15:51:17,255 ERROR [STDERR] action1
      15:51:17,279 ERROR [STDERR] rerender 1
      15:51:17,280 ERROR [STDERR] rerender 1
      15:51:17,280 ERROR [STDERR] rerender 1
      15:51:17,280 ERROR [STDERR] rerender 1
      15:51:17,281 ERROR [STDERR] rerender 1
      15:51:17,282 ERROR [STDERR] rerender 1
      15:51:17,282 ERROR [STDERR] rerender 3
      15:51:17,283 ERROR [STDERR] rerender 2
      

      why is testRerender2 beeing processed? normally this would not be a problem, but i have a component i wrote (a threaded post view which uses the child components as post viewer, like rich:column in dataTable) fails in this case, because one of the child components gets rerenderd without the viewer knowing about it. therefor the rowvar does not get set and things go ugly. the only solution i found is to set the attribute renderRegionOnly of the a:region to true. but then i can not rerender anything outside this region, even if add them to the reRender attribute of the commandLink.

      so, at least, i would like to saveguard my component against this, any pointers at how to do this would be very welcome.

        • 1. Re: AJAX reRender
          ilya_shaikovsky

          Rendered property of the components evaluated many times during request. You should clear understand it working with such constructions.

          You could limit some processing using regions and attributes limittolist and ajaxSingle. By default all the component tree processed and encoded as usually. Read more at ajax attributes page at our livedemo.