0 Replies Latest reply on Apr 5, 2013 8:29 AM by lostiniceland

    How to handle service-calls in a portlet-environment

    lostiniceland

      Hello everyone,

       

      first I should mention that I posted the exact same question on Stackoverflow but I havent got any answer yet and the issue is quite important to plan my next steps. Thats why I post the question here and I hope the GateIn-Community can help me. Thanks

      ----------------------------------------------------------

       

       

      I am looking for alternatives to a session-flag when using a portlet (jsr-286) together with JSF 2.0.

       

      The problem is that I have to use @PostConstruct to load data from the backend. The reason for loading data in a postconstruct rather than after a action is because the portlet is loaded within a dynamic portlet-page at runtime. So when the portlet is loaded the first time, RESTORE_VIEW is called for the RenderRequest and several Webservices are called to load some data.

       

      When triggering an action on the page I run into the problem with the two requests in a portlet-runtime: first the ActionRequest is handled, again RESTORE_VIEW is called, and the LifeCycle continues till the end of INVOKE_APPLICATION. Now, the RenderRequest is processed which calls RESTORE_VIEW and RENDER_RESPONSE.

       

      My BackingBeans are all @RequestScoped and this means that @PostContruct is called twice when invoking an action, and this causes an performance issue because the webservices are also called twice. The simplest idea now was to use a session-flag within the portlet that is used to control when backend-services need to be called and when not.

       

      Are there better alternatives to this approach? How do other people handle Bean-Initialization in a Portlet-JSF2-Environment?