3 Replies Latest reply on Feb 10, 2009 9:58 AM by abuit

    Omit part of the view when using a4j:region with renderRegio

      Hello RichFaces designers,

      I'm a developer of a rich JSF application that uses a few facelets and alot of dynamic JSF components, mostly RichFaces components.

      When any component makes a server call, the whole view is built in the first phase of the JSF LifeCycle.

      Due to the size of our application, a JSF LifeCycle generates about 5k to 20k java objects in the restore view phase, depending on the components in the view, and has to garbage collect them at the end of the JSF LifeCycle. Now imagine this with thousands of users.

      However, most of the time this isn't necessary at all. Imagine a tab panel with ajax switch. When i perform an action on the first tab, I don't need any java objects of the second tab.

      This is why I hoped that an a4j:region with renderRegionOnly="true" would cause the ViewState to only restore the view limited to the a4j:region, since it can't rerender objects outside the region anyway.

      I hope you can imagine what impact this would have on our application. Instead of 20k java objects (4 tabs with a rich page on it), it would go down to 5k. Even better, for a simple form it would only restore the form, so instead of 20k objects, only 200 objects.

      Unfortunately, I experienced that server calls from an a4j:region cause the whole viewroot to be restored. I did some tests with the RichFaces demo, and the results were the same.

      The Ajax Region description is as following:
      Ajax region is a key ajax component. It limits the part of the component tree to be processed on the server side when ajax request comes. Processing means invocation during Decode, Validation and Model Update phase.

      Would it be hard to add the Restore View phase? Maybe add another attribute to the a4j:region where you can set this?

      Thank you for your time, keep up the good work.

        • 1. Re: Omit part of the view when using a4j:region with renderR

          Seeing as there are no replies on this topic yet, I assume it isn't easy to add functionality like this.

          Still, I would like to see a discussion about this.

          Am I the only one with a large rich application, that takes up quite a few MB of memory during the RESTORE_VIEW phase?

          Would you like to see functionality that allows you to restore only a part of the view to save memory useage?

          Does anyone think this would be a great improvement to JSF in general?

          Is there any work-around to get funcionality like this?

          This particular issue is becoming a bottleneck to our application, so some feedback would be great :)

          • 2. Re: Omit part of the view when using a4j:region with renderR
            alexsmirnov

            Sorry, but a4j:region has no relations to the JSF view state saving and restoring, but view processing only.
            Are you sure about view tree size at the request processing phase ? Most common memory consumption problem is a size of saved views history. You can reduce that size using some optimization tricks:
            1) With the server-side view saving, reduce number of stored views by the "com.sun.faces.numberOfViewsInSession" and "com.sun.faces.numberOfLogicalViews" initialization parameters ( see http://wiki.glassfish.java.net/Wiki.jsp?page=JavaServerFacesRI for a reference ).
            2) Mark output-only JSF components as "transient" where possible. In the Facelets environment, you can even mark as transient entire <f:view> and set "facelets.BUILD_BEFORE_RESTORE" init parameter to "true" ( Warning: that change could significant affect JSF behaviour, thus it not always applicable ).
            3) Use client-side view state saving. It will reduce memory consumption but significant increase a network traffic at the same time.

            • 3. Re: Omit part of the view when using a4j:region with renderR

              alexsmirnov, thank you for your reply!

              I'm sure the memory spikes occur during the JSF LifeCycle. When the state is serialized, it doesn't use much memory, only when the view is active as java objects.

              Regarding point one; Our application uses only one view per client, everything 'happens' in one page. The components are built dynamic, so there is no need to have more than one page, except for a login page. The amount of views per client is already set to one.

              Regarding point three; This is not an option due to the traffic. And as I mentioned a bit earlier in this post, the serialized view is not a problem.

              Regarding point two; This is definately something I will look into, thanks for this suggestion. However, I doubt this will affect the memory consumption of a restored view.

              I see that there is no default method to omit part of the view. Does anyone know if there is a work-around possible to omit parts of the view during the first JSF Phase, or where I could find information about this?