6 Replies Latest reply on Apr 14, 2010 1:34 PM by beligum

    a4j Delayed render zone

    dinoliste

      Hello

      I am trying to create a delayed render zone.
      My site contain a javascritpt combobox with a lot of values and a lot of db stress for extracting these values, so i would like to create a a4j zone that will be rendered after (for example with 10ms delay) the page main content zone is loaded.
      In this way i can give the user a page and use the time between the load and his click on combobox to load the combobox content.

      Can you, please, give me some advices on how to do this?

      Thank You
      Dino

        • 1. Re: a4j Delayed render zone

          a4j:support has a requestDelay attribute where you can define the delay.

          • 2. Re: a4j Delayed render zone
            dinoliste

            I tested this property and it works as you say, but the action is fired by an event, and i think it does not fit to my needs. The oncomplete event doesent work for me, and i read about it's incompatibility with ie and the action artificially generated from javascript can be stoped by popup blokers.

            I will give you an example so the requsts to became more clear:
            i have the next fragment loaded (it is loaded with ajax, not with the whole page )

            <a4j:outputPanel id="myCenterPanel">
            text to be before....
            text to be after...
            </a4j:outputPanel>


            and after n millisecounds i have to obtain the next fragment without rerendering the "text to be before...." and "text to be after..." text:

            <a4j:outputPanel id="myCenterPanel">
            text to be before....
            <a4j:outputPanel id="myRows"> <!-- delayed loaded fragment -->
             item1
             item2
             ......
            </a4j:outputPanel>
            text to be after...
            </a4j:outputPanel>


            Another question related to this problem:
            How can you make a zone not rendered at the begining and render it after an event from a4j? I tried to add to this zone rendered=false and then in another component reRender=MyZone, and it doesent work. If i let it to rendered=true it is shown/loaded from the begining.


            • 3. Re: a4j Delayed render zone

              You should not point with reRender to the component that might have rendered="false". Point to one of the parent component is a right way to go.
              I mentioned the reason several times. So, it looks like a good candidate for FAQ.

              Delivering the update, but applying it with timeout is not a future of ajax4jsf. I see only the way with second ajax request triggered by oncomplete

              BWT, what is the problem with oncomplete you spoke about?

              • 4. Re: a4j Delayed render zone
                dinoliste

                It could work this way but i need a zone that is not render initial and to render it after an event (in this case the delayed onload). Is the only way to do this by keeping a flag on the server and send the content only on the second request of the zone, or can the ajax4jsf do this?

                It would be useful if ajax4jsf could split some parts of a rendered zone (split defined by user) to be rendered in background later use.

                I know that the timeout is used for skipping multiple requests, but is a good thing when you want to do exotic stuff like my problem. I would be happy if would be included in next releases.

                Sorry about the oncomplete i tried myself and is working, seems i was misinformed :)

                • 5. Re: a4j Delayed render zone

                  May be you can use a javascript what replace style="display:none" with style="display:block" by timer.

                  • 6. Re: a4j Delayed render zone
                    beligum

                    You can use a a4j:poll to get the requested behaviour:

                     

                    <a4j:poll id="pollerId"
                    reRender="whatToRerender"
                    limitToList="true" interval="5000"
                    ajaxSingle="true" />

                     

                    The trick is to set limitToList to "true", but _not_ include the ID of the poller in it's reRender list.

                    This way, the reRender will fire once after the specified interval.

                     

                    Works for me.

                     

                    b.