4 Replies Latest reply on Jun 29, 2010 5:24 AM by ilya_shaikovsky

    Toggle Panels Rendering When Closed (lazy loading help)

    shamu25

      I'm using a series of rich:simpleTogglePanels to delay loading parts of my page. I load the first one open, but the rest are rendered

      in the closed state.  In my first panel, I have an a4j:commandLink to perform an action and rerender the content of the first panel. But,

      when the post happens for the a4j:commandLink the content in all the simpleTogglePanels gets rendered even though they are closed.

       

      I'd like to use the closed panels to delay loading of the content. This works when the page is initially shown, but when I click on the link all their content is rendered;

      beans are created and subsequent service calls are made. After the page update in the browser, the panels are still in a closed state, but the

      a4j:commandLink required extra time because of all the bean  creations. Does anyone have suggestions on how to prevent this?

       

       

      Example Code:


      <rich:simpleTogglePanel id="p1"switchType="ajax'
                       opened="true">

           <s:div id="p1_content">

                <a4j:commandLink value="Edit"
                                             action="#{my.Bean1.actionMethod}"
                                             reRender="p1_content" />

           </s:div>

      </rich:simpleTogglePanel>



      <rich:simpleTogglePanel id ="p2" switchType="ajax'
                        opened="false">

           <h:outputText value="#{my.Bean2.heavyProcessValue}" />                            

      </rich:simpleTogglePanel>

       

      You can see p2 is in a closed state, I didn't want to call my.Bean2.heavyProcessValue until the user opens p2. This works correctly

      when the page is initially shown, but once I select the Edit link in p1 the bean in p2 gets called. This slows down the processing for p1 even though the reRender is scoped to its local div.

       

      I believe this is a bug or my misunderstanding of how the toggle panels work.  I have tried setting limitToList on the a4j:commandLInk. And that does work, but I might need to set a message, so I didn't want to use that flag. I thought as long as p2 is

      in a closed state it wouldn't render; but this is not the case.

       

      Any help would be appreciated.

       

      Thanks,

      Chris

        • 1. Re: Toggle Panels Rendering When Closed (lazy loading help)
          ilya_shaikovsky

          use regions or ajaxSingle attributes in order to limit processing zones as much as possible. this will optimize processing much.

           

          use limittolist everywhere where appropriate in order to optimize rendering. (in other case auto-updateable outputPanels searched in the whole tree and that could be caused in unnesessary data calls.)

          • 2. Re: Toggle Panels Rendering When Closed (lazy loading help)
            shamu25

            Ilya,

              Thank you for the response. I tried wrapping the internals of panel 1 inside a a4j:region. But, when I click on my a4j link and specify the reRender using another div within the region, Panel 2 - which is outside the region - is getting processed on the server. I've hooked up a debugger and it hits my breakpoint on a bean that should only be used when rendering Panel 2.

             

               Is there something special with the rich:SimpleTogglePanel? Maybe it always has the ajaxRendered attribute to true? I tried setting it to false and it did not help.

             

                If I set the "limitToList" flag on my a4j:commandLink, Panel 2 does not update. I would like to prevent to the processing of Panel 2 while processing commands in Panel 1 without having to use limitToList. The a4j:Region did not work.

             

            Any other suggestions would be appreciated.

            • 3. Re: Toggle Panels Rendering When Closed (lazy loading help)
              shamu25

              iLya,

                 Let me narrow my description down to what I believe is the core issue. When a rich:simpleTogglePanel is in the closed state, the contents within the panel should never be rendered. It should act as if the contents is rendered="false". In my testing, the contents

              are rendered on the server.

               

               

                 I'm starting with my panels in the closed state with switchType="ajax". The contents of the panels are getting rendered anyways. This doesn't happen on initial page load, it happens when an a4j:commandLink is clicked.

               

              Thanks,

              Chris

              • 4. Re: Toggle Panels Rendering When Closed (lazy loading help)
                ilya_shaikovsky

                your issues sounds completelly like https://jira.jboss.org/browse/RF-3341. And the calls you mentioned occurs not at decode/validate/update phases (which actually getting limited by region), but at rendering phase while the framework looking for autoupdateable zones. And this could be limited only with limitolist=true. (the other workaround is region with renderRegionOnly - but this solution not really convenient as nothing outside the region could be reRendered even specified in reRender of the component)

                 

                https://jira.jboss.org/browse/RF-8881 - created for 4.x.