5 Replies Latest reply on Apr 28, 2011 6:23 AM by diabolique

    JSF Portlet - managed bean lifecycle issue

    diabolique

      Hi,

       

      My configuration:

      -gatein 3.1

      -jboss AS 5.1

      -jsf 1.2

      -portletbridge 2.0

      -richfaces 3.3.3.final

       

      In a custom web application with jsf (+ jsf webui extension) I have some method for manage lifecycle (init(), prerender(), preprocess(), afterRenderResponse(), ... ).

       

      This methods are provided by the com.sun.jsfcl.app.AbstractPageBean (jsfcl) or com.sun.rave.webui... (webui extension).

       

      In my portlet I tried with jsfcl and webui library, but nothing is called!

       

      Is the problem the portlet bridge? Must I define a (other) view-handler in the faces-config.xml for this "extension"?

       

      Which configuration (lib, xml,..) for have control with those lifecycle methods?

       

      The problem is that with a session bean actually I cannot re-init the data when refresh the page!

       

       

      Thanks

        • 1. Re: JSF Portlet - managed bean lifecycle issue
          diabolique

          Any help?

           

          I've this requirement: a "page scope" managed bean (request is too short, session is too long and not is restored when I recall a page from menu; page bean is available from jsf 2.0 that isn't supported by portlet bridge 2.0, it's true?)

          I've tryed with:

          -rich faces "@keepalive" but don't work with gatein --> is the same of a session scoped bean

          -myfaces tomahawk extension --> don't work: the plugin start, but the bean is a simple request bean, nothing is stored

           

          Anyone has this same issue/requirement? Possible?

          • 2. Re: JSF Portlet - managed bean lifecycle issue
            wesleyhales

            JBoss Portlet Bridge 3.0 supports JSF 2.0 and is in Alpha atm.

             

            I have no idea if you need to define another view handler as I haven't used that specific extension. Your may need to do some kind of init() when you need to refresh your bean. It would help if you could attach a sample project with source.

            • 3. Re: JSF Portlet - managed bean lifecycle issue
              diabolique

              Thanks for the reply.

               

              But in production I can't use an alpha version.

               

              Yes, I need an init(), but how can I call this init() method at page reload/refresh (in particular: when the call isn't a postback)??

               

              With jsf extension, tomahawk, rich faces @keepalive, this is possible, but with portlet bridge + jsf 1.2 + richfaces?

              • rich faces @keepalive on a request managed bean: the bean became a simple SESSION bean (at page reload/refresh it isn't reinitiated)
              • tomahawk (myfaces plugin): the plugin is registered, but the bean is a simple request bean (reinit for all action)
              • jsf webui extension: problem in first post

               

              So, HOW CAN I REINIT A JSF SESSION MANAGED BEAN AT PAGE REFRESH/RELOAD (when isn't a postback)?

               

              thanks

              • 4. JSF Portlet - managed bean lifecycle issue
                diabolique

                any help?

                • 5. JSF Portlet - managed bean lifecycle issue
                  diabolique

                  This is my workaround:

                   

                  -in every xhtml page (portlet1 has an initial page page1, portlet2 has an initial page page2,...) I've add an <h:outputText value="{Portlet1JSFBean.clean}">

                  -in Portlet1JSFBean, Portlet2JSFBean,... "clean" is a simple String variable

                  -in the getter method I've add some custom code:

                  public String getClean() {

                                      if (<httpSession>.getAttribute(PORTLET_ALIVE) != null && !<httpSession>.getAttribute(.PORTLET_ALIVE).equals(SESSION_BEAN_PORTLET1))

                    //cleanJsfSession

                  FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove(SESSION_BEAN_PORTLET1_NAME); 

                  return clean;

                            }

                   

                  -in every constructor of jsf beans:

                  <httpSession>.setAttribute(PORTLET_ALIVE, SESSION_BEAN_PORTLET1_NAME);

                   

                   

                  In this way, every portlet/jsfBean says: "I'm the current portlet alive", and when I change the portal page (see another portlet), getClean() reinizialize the current session bean.

                   

                   

                  @keepalive  (richfaces) instead, is ok for a page bean, but only for navigation in the specific portlet. If you change the portal page, the jsf bean (session, request, or page is the same) isn't reinizialized.

                   

                   

                  Is ok ?

                   

                   

                  thanks