6 Replies Latest reply on Oct 22, 2007 4:49 AM by bardolf

    Invoke ajax request programatically

    bardolf

      Hi all,
      maybe it is a stupid question, but i didn't fin any solution. I would like to invoke rerender request for a component programatically. For example I want to react on extern signal.
      I expect that I found something like:
      1. creation ajax event and reaction on this event would be rerender.
      2. or I can call rerender directly on a component.

      I hope the problem is clear. If not, maybe following example will clarify it:
      Lets have HtmlOutputText and rerender it every 10s. Do not use ajax:poll, use internal Timer.

      Thanks for every idea!
      Bardolf

        • 1. Re: Invoke ajax request programatically

          a4j:jsFunction is an entry point for Ajax call invokation from client-side javascript

          • 2. Re: Invoke ajax request programatically
            bardolf

            Hi,
            I would like to invoke it on server-side. Maybe your point is helpful also for this situation, I'm not sure now.
            Clarification: source of invocation should be an event on server-side.

            Thx

            • 3. Re: Invoke ajax request programatically

              if so, look at a4j:push

              • 4. Re: Invoke ajax request programatically
                bardolf

                Hi,
                thank you for you response, you are doing great job, but i do not want to use a4j:push. It is not satisfy the requirement "use internal timer" in example. For more clarification:
                I have TimerTask in Java code. And this TimerTaks has to invoke the ajax rerender request on server side.
                One more thing: i don't really sure how a4j:push works. I have seen a lot of questions on it, but no good example. So maybe connection a4j:push with something inside - for example required TimerTask would be fine. But I don;t know.

                Thx anyway B.

                • 5. Re: Invoke ajax request programatically

                  Two things:

                  1.) I wanna have a good example for a4j:push, too. :-)

                  2.) @bardolf: It is not possible to do that what you want. This depends not on Richfaces components, JSF but on the whole web architecture itself. The server is not allowed to send responses to a client without request. a4j:push could be the best alternative to simulate such behavior (if one knows how to use it).

                  • 6. Re: Invoke ajax request programatically
                    bardolf

                    Yes, you are right! So easy explanation and that's right. I cannot response, if I wasn't asked. I think is has something to do with a4j:push, but explanation, that the a4j:push is little bit different to a4j:poll, as described in manual, is not enough for me. But thank you, I will focus this direction.
                    B.