2 Replies Latest reply on May 31, 2007 7:19 PM by Daniel Young

    PAGE context and Ajax4JSF

    Daniel Young Novice

      Hi all,

      Are there any plans (is it even technically possible?) to get PAGE scoped components to work with a page that uses Ajax4JSF?

      I was using a PAGE-scoped @Factory @DataModel previously, to display data to the user that gets modified by other asynchronous processes - ie: i wanted the data model to refresh on each request. However, this failed when I had form fields with Ajax4JSF because the serialized page state is not available when Ajax4JSF goes through the JSF lifecycle to process the validations.

      I had to solve it by using a long-running conversation with judicious use of @End on most of the other actions on my bean, which seems a bit of a hack.

      Is there a better way? Or should I just avoid the a4JSF validation and PPR on this kind of page?

      thanks kindly,
      Daniel.

        • 1. Re: PAGE context and Ajax4JSF
          Gavin King Master

           

          the serialized page state is not available when Ajax4JSF goes through the JSF lifecycle to process the validations


          I'm sure that's not correct. Ajax4JSF does resubmit the serialized state back to the server.


          i wanted the data model to refresh on each request.


          Then what you need to do is re-render the whole f:view. If you don't re-render the ViewRoot, then the PAGE scope attributes won't be updated on the client side.

          If you use reRender="theViewRootId", everything should work fine.

          • 2. Re: PAGE context and Ajax4JSF
            Daniel Young Novice

            Hi Gavin,

            Thanks for the reply.

            "gavin.king@jboss.com" wrote:
            the serialized page state is not available when Ajax4JSF goes through the JSF lifecycle to process the validations


            I'm sure that's not correct. Ajax4JSF does resubmit the serialized state back to the server.


            I'd have thought so too, but I read something on the forums which led me to believe this was the problem (can't find the link now). Perhaps the behaviour I'm seeing is actually to do with my @Factory/@DataModel usage.

            Here's what's happening...
            @DataModel(scope = ScopeType.PAGE)
            private List<Batch> batchList;
            
            @Factory("batchList")
            public void search() { ... }
            


            Now, every time focus leaves an input box that has Ajax4JSF validation on it, the search() method gets called on the server. I assumed this was because the Ajax4JSF request does not have the page scoped "batchList" available, so the @Factory gets called. What do you think?

            "gavin.king@jboss.com" wrote:

            i wanted the data model to refresh on each request.


            Then what you need to do is re-render the whole f:view. If you don't re-render the ViewRoot, then the PAGE scope attributes won't be updated on the client side.

            If you use reRender="theViewRootId", everything should work fine.

            Those requests aren't PPR/ajax.. but thanks for that tip because if I solve the above a4jsf validation problem, I will probably change this later on and I would have just reRender'ed the data table, not the whole view.

            cheers,
            Daniel.