7 Replies Latest reply on Jun 9, 2011 6:05 AM by Ján Jamrich

    How limitRender works ?

    Fred Fred Newbie

      Hi,

      I having trouble using the partial rendering.

       

      Here is the problem:

      I've got two outputPanel. When I click (ajax) on a commandLink, instead of refreshing the correct panel, it refresh the all page.

      The code is following.

       

      The thing I wanted to do is simple: refresh only the affected panel, which lead to reduce the number of SQL query in the database, because each Managed Bean (MB_.....) is doing via EJB, some SQL query

       

      Can you help me ? is there a solution ?

      thanks !

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

       

      <html xmlns="http://www.w3.org/1999/xhtml"

        xmlns:ui="http://java.sun.com/jsf/facelets"

        xmlns:h="http://java.sun.com/jsf/html"

        xmlns:f="http://java.sun.com/jsf/core"

        xmlns:a4j="http://richfaces.org/a4j"

        xmlns:rich="http://richfaces.org/rich"

                >

       

        <f:view contentType="text/html">

        <h:head/>

        <h:body>

         <!-- ############# -->

         <!-- Panel state   -->

         <!-- ############# -->

         <rich:popupPanel id="statPane" autosized="true" modal="false">

         <h:graphicImage name="6-1.gif" library="images"/>

                         Wait please...

         </rich:popupPanel>

         <a4j:status onstart="#{rich:component('statPane')}.show()" onstop="#{rich:component('statPane')}.hide()" />

       

        <!-- ############# -->

        <!-- Main table    -->

        <!-- ############# --> 

        <table>

        <tr valign="top">

        <td>

         <a4j:outputPanel id="AuthorTest" layout="block">

          <h:form>

           <rich:dataTable id="AuthorTestTable" value="#{MB_Author.getAuthorList()}" var="author">

            <rich:column>

            <h:outputText value="#{author.firstname}"/>

            </rich:column>

           </rich:dataTable>

          </h:form>

         </a4j:outputPanel>

         </td> 

       

        <td>

         <a4j:outputPanel id="EditorTest" layout="block">

          <h:form> 

           <rich:dataTable id="EditorTestTable" value="#{MB_Editor.getEditorList()}" var="editor">

            <rich:column>

             <h:outputText value="#{editor.name}"/>

            </rich:column>

            <rich:column>

             <a4j:commandLink render="EditorTest" value="X" execute="@form" limitRender="true"/>

            </rich:column>

           </rich:dataTable>

         </h:form>

         </a4j:outputPanel>

        </td>

        </tr>

        </table>

        </h:body>

        </f:view> 

      </html>

        • 1. Re: How limitRender works ?
          Kike Gil Novice

          you try to use execute="@this" and maybe you would including outputpanel inside the form

          • 2. Re: How limitRender works ?
            Fred Fred Newbie

            In fact,

            the returned data is only the thing that was changed. so from this point, this is good.

            In the other hand, I cannot understood why both Managed Bean are called.

             

            In this page you've two Managed Bean.

            -->MB_Author

            -->MB_Editor

            if I do any ajax action, the MB_Author bean is called, even if the datatable associated with it is never rendered.

             

            Do you see what I want to mean?

            How can I 'tell' my Managed Bean (or else) : this is not you we are asking for ?

             

             

            Thanks a lot

            • 3. Re: How limitRender works ?
              Kike Gil Novice

              i think with execute="@form" render all forms, and  call all bean that you use in the forms, but it is only a idea

              • 4. Re: How limitRender works ?
                Fred Fred Newbie

                I've set:

                @this

                @form

                = all the same.

                 

                The problem is elsewhere. I've made some change to my code, to test the fact that the bean is always called.

                this is the test code for now: (look, i've added the outputText -in bold- of a variable that take the systemTime when it's called).

                 

                  <table>

                  <tr valign="top">

                                                        <td>

                  <h:form>

                  <a4j:outputPanel id="AuthorTestRegion" layout="block">

                  <h:outputText value="${MB_Author.currentSystemTime}"/>

                  <rich:dataTable id="AuthorTestTable" value="#{MB_Author.getAuthorList()}" var="author">

                  <rich:column>

                  <h:outputText value="#{author.firstname}" id="author_row_firstname"/>

                  </rich:column>

                  </rich:dataTable>

                  </a4j:outputPanel>

                  </h:form>

                                                        </td> 

                                                        <td>

                                                                  <h:form> 

                  <a4j:outputPanel id="EditorTestRegion">

                  <rich:dataTable id="EditorTestTable" value="#{MB_Editor.getEditorList()}" var="editor">

                  <rich:column>

                  <h:outputText value="#{editor.name}" id="editor_row_name"/>

                  </rich:column>

                  <rich:column>

                  <a4j:commandLink render="editor_row_name" value="X" execute="@this" limitRender="true"/>

                  </rich:column>

                  </rich:dataTable>

                  </a4j:outputPanel>

                  </h:form>

                                                        </td>

                                              </tr>

                  </table>


                 

                If this variable is read, it logged a message.

                Executing this code the first time the page is loaded, is resulting in:

                - executing the two bean, by calling the getEditorList and the getAuthorList and the currentsystemTime functions.

                --> it's a normal way

                 

                - calling the commandLink has an unexpected behaviour:

                --> the getAuthorList function is called (also this dataTable is not asked to be rendered)

                --> the currentSystemTime variable IS NOT READ (so the function getCurrentSystemTime is not called)

                 

                is there a bug in the dataTable --> everytime it's rendered, even if the component ID is not referenced for refresh ?

                • 5. Re: How limitRender works ?
                  Kike Gil Novice

                  you don't want render "AuthorTestRegion" when you pulse the link, is it?

                   

                  you try execute="@this" render="@this EditorTestRegion" 

                  • 6. Re: How limitRender works ?
                    Fred Fred Newbie

                    argh,

                    no more good. i've done @this. I can't control the rendering:

                    -> I effectively render the EditorTestRegion, and not the AuthorTestRegion : this is good.

                    -> also, not rendering the AuthorTestRegion is still driving to read the Managed Bean property: getAuthorList(), this is not normal.

                     

                    see my log:

                     

                    --- below the log the first time the page is loaded ---

                    INFO: [PRE-FILTERING.START - Request: http://localhost:8080/myHome/jsf/test/test-limitedRender.jsf

                    INFO: [MB_Author,getCurrentSystemTime] - retreiving the date time

                    INFO: [EJB_Author, getAuthorList] - Entering procedure

                    INFO: [EJB_Author, getAuthorList] - Total record found: 69

                    INFO: [MB_Author,getauthorList] - retreiving the author list

                    INFO: [MB_Editor,getEditorList] - retreiving editor list

                    INFO: [EJB_Editor, getEditorList] - Entering procedure

                    INFO: [EJB_Editor, getEditorList] - Total record found: 23

                    INFO: Total render time: 53 ms

                     

                    as you see, the retreiving of the date time is effective. This normal, because we are rendering all the component on the page

                     

                    --- below the log after the link being clicked ---

                    INFO: [PRE-FILTERING.START - Request: http://localhost:8080/myHome/jsf/test/test-limitedRender.jsf

                    INFO: [MB_Editor,getEditorList] - retreiving editor list

                    INFO: [EJB_Editor, getEditorList] - Entering procedure

                    INFO: [EJB_Editor, getEditorList] - Total record found: 23

                    INFO: [EJB_Author, getAuthorList] - Entering procedure

                    INFO: [EJB_Author, getAuthorList] - Total record found: 69

                    INFO: [MB_Author,getauthorList] - retreiving the author list

                    INFO: Total render time: 26 ms

                     

                    then, the date time variable is never read, because we don't render the AuthorTestRegion. This is logical !

                    But why the dataTable component still try to update itself from it's data !!! (in bold in the log)

                    I think it's a bug.

                     


                    • 7. Re: How limitRender works ?
                      Ján Jamrich Newbie

                      Hi Fred,

                      if you think its bug, could you fill JIRA for this issue eith reference to this thread, please?

                      Thanks

                      JJa