1 Reply Latest reply on Apr 9, 2009 6:32 PM by gonorrhea

    Rerender question

    fscan

      hello,


      i replied to an old post but i figure i start a new thread with some examples. 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 i would like to saveguard my component against this, any pointers at how to do this would be very welcome.





        • 1. Re: Rerender question
          gonorrhea

          You're probably using the right approach.  Otherwise, it seems that both forms are reRendered during the JSF lifecycle.


          from Practical RF book:


          When renderRegionOnly="true", only the current region’s components mentioned in reRender will
          be rerendered. Any components outside the current region will not be rerendered.