6 Replies Latest reply on Jan 10, 2008 4:08 PM by Jing Fu

    PortletBridge: Facelets not working

    Phil Eberle Newbie

      Hi,

      I thought I'd give the new RichFaces JSR-301 PortletBridge a try to finally have proper support for RichFaces components in my portlets, but it seems like my Facelets CompositionComponents aren't displayed anymore. No error, it just shows nothing in the portlet. It used to work when using the AjaxFacesPortlet class directly.

      Anyone experiencing the same behavior? It might easily be a configuration error, took me quite a while to get this far. Or isn't it implemented yet (still in beta as far as I know anyway). The ajaxPortlet sample that comes with the richfaces-source also doesn't seem to be using Facelets.

      I am using the JBoss Portal 2.6.3.GA bundle with the included JBoss 4.2.2GA, the latest Facelets jar (1.1.3) and self compiled richfaces and portletbrige jars (built from the richfaces-ui-3.1.3.GA source zip).

      My web.xml (with the FaceletPortletViewHandler set):

      <web-app >
      
       <display-name>FooPortlets</display-name>
       <description>Foo Portlets</description>
      
       <context-param>
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>com.sun.faces.verifyObjects</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>facelets.SKIP_COMMENTS</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>facelets.VIEW_MAPPINGS</param-name>
       <param-value>*.xhtml</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
       <param-value>
       org.ajax4jsf.portlet.application.FaceletPortletViewHandler
       </param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>server</param-value>
       </context-param>
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
      
       <filter>
       <display-name>Ajax4jsf Filter</display-name>
       <filter-name>ajax4jsf</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>ajax4jsf</filter-name>
       <servlet-name>FacesServlet</servlet-name>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
      
       <servlet>
       <servlet-name>FacesServlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>FacesServlet</servlet-name>
       <url-pattern>/faces/*</url-pattern>
       </servlet-mapping>
      
      </web-app>
      


      My faces-config.xml (with the viewhandler, statemanager and contextfactory set):
      <faces-config>
      
       <!-- Richfaces configuration -->
       <application>
       <view-handler>
       org.ajax4jsf.portlet.application.PortletViewHandler
       </view-handler>
       <state-manager>
       org.ajax4jsf.portlet.application.PortalStateManager
       </state-manager>
       </application>
       <factory>
       <faces-context-factory>
       org.ajax4jsf.portlet.context.FacesContextFactoryImpl
       </faces-context-factory>
       </factory>
      ...
      </faces-config>
      


      And finally my portlet.xml:
       <portlet>
       <portlet-name>AlarmPortlet</portlet-name>
       <display-name>Alarm Portlet</display-name>
      
       <portlet-class>
       javax.portlet.faces.GenericFacesPortlet
       </portlet-class>
       <init-param>
       <name>javax.portlet.faces.defaultViewId.view</name>
       <value>/jsf/alarm/view.xhtml</value>
       </init-param>
       <init-param>
       <name>javax.portlet.faces.defaultViewId.help</name>
       <value>/jsf/alarm/help.xhtml</value>
       </init-param>
       <!-- disable portlet caching -->
       <expiration-cache>-1</expiration-cache>
       <supports>
       <mime-type>text/html</mime-type>
       <portlet-mode>VIEW</portlet-mode>
       </supports>
       <supported-locale>en</supported-locale>
       <supported-locale>de</supported-locale>
       <resource-bundle>AlarmResourceBundle</resource-bundle>
       <security-role-ref>
       <role-name>Admin</role-name>
       <role-link>Admin</role-link>
       </security-role-ref>
       <security-role-ref>
       <role-name>User</role-name>
       <role-link>User</role-link>
       </security-role-ref>
       </portlet>
      


      Any help is appreciated :-)

      Thanks in advance

      Cheers
      Phil

        • 1. Re: PortletBridge: Facelets not working
          Wesley Hales Master

          Are you using this demo (http://anonsvn.jboss.org/repos/portletswap/portlets/src/framework/RichFacesPortlet/)?

          If so, ensure you have updated the maven pom since 1-7-0. The portlet bridge changed locations.

          • 2. Re: PortletBridge: Facelets not working
            Phil Eberle Newbie

            Hi,

            last time I updated the RichFaces demo was on monday, the full demo came on tuesday/wednesday :-).

            I'll take a look at it and post back my results.

            Thanks!

            • 3. Re: PortletBridge: Facelets not working
              Jing Fu Newbie

              I am having the exact same problem. Nothing shows up, but no error in log either. Below are the 2 links where I download the portlet bridge. Does below location sound correct to you?

              http://repository.jboss.com/maven2/org/richfaces/extensions/portletbridge/portletbridge-api/3.1.3.GA/
              http://repository.jboss.com/maven2/org/richfaces/extensions/portletbridge/portletbridge-impl/3.1.3.GA/

              I also used to use AjaxFacesPortlet directly, and put "org.ajax4jsf.portlet.PortletAjaxContext" in the "faces-config.xml", but it has issues with JSF managed bean session scope whenver I use Ajax. Does this sounds familiar?

              Anyway any pointer would be appreciated.

              • 4. Re: PortletBridge: Facelets not working
                Phil Eberle Newbie

                Concerning Facelets: configuration error :-) I didn't pass the path to my taglib in the web.xml. I don't know why it worke before, maybe I just overwrote it when I updated my configuration. At least it's easy to fix:

                <context-param>
                 <param-name>facelets.LIBRARIES</param-name>
                 <param-value>/WEB-INF/facelets/tags/foo.taglib.xml</param-value>
                </context-param>
                
                


                That's one of the things I learned to love about Facelets: Verbose error messages that pop right into your eye :-)

                I also get quite a few 'Prefix for attributes in portlet session scope not found' warnings. I didn't dig into that yet, I assumed it was caused by the early development stage of the AjaxFacesPortlet. However, it still seems to happen with the portlet bridge (but hey, I'm using an svn snapshot). I pasted the warning below, but won't take a further look at it until tomorrow. BTW: It doesn't seem to affect my app, it just fills the log (quite often indeed as I use <a4j:poll />).

                Thanks again for the hint Wesley and, according to the svn log, thank you even more for the comprehensive RichFacesPortlet :-)

                18:48:46,072 WARN [lifecycle] executePhase(RESTORE_VIEW 1,org.ajax4jsf.portlet.context.FacesContextImpl@1e9b9ae) threw exception
                javax.faces.FacesException: Prefix for attributes in portlet session scope not found
                 at org.ajax4jsf.portlet.context.ServletContextImpl.getSessionPrefix(ServletContextImpl.java:255)
                 at org.ajax4jsf.portlet.context.ServletContextImpl.getSession(ServletContextImpl.java:352)
                 at org.ajax4jsf.portlet.application.PortletStateHolder.getInstance(PortletStateHolder.java:62)
                 at org.ajax4jsf.portlet.application.PortalStateManager.restoreStateFromSession(PortalStateManager.java:39)
                 at org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:221)
                 at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:290)
                 at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:316)
                 at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
                 at org.ajax4jsf.application.AjaxViewHandler.restoreView(AjaxViewHandler.java:159)
                 at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
                 at org.ajax4jsf.application.AjaxViewHandler.restoreView(AjaxViewHandler.java:159)
                 at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:141)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:143)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                 at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                 at java.lang.Thread.run(Thread.java:619)
                18:48:46,074 ERROR [[FacesServlet]] Servlet.service() for servlet FacesServlet threw exception
                javax.faces.FacesException: Prefix for attributes in portlet session scope not found
                 at org.ajax4jsf.portlet.context.ServletContextImpl.getSessionPrefix(ServletContextImpl.java:255)
                 at org.ajax4jsf.portlet.context.ServletContextImpl.getSession(ServletContextImpl.java:352)
                 at org.ajax4jsf.portlet.application.PortletStateHolder.getInstance(PortletStateHolder.java:62)
                 at org.ajax4jsf.portlet.application.PortalStateManager.restoreStateFromSession(PortalStateManager.java:39)
                 at org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:221)
                 at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:290)
                 at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:316)
                 at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
                 at org.ajax4jsf.application.AjaxViewHandler.restoreView(AjaxViewHandler.java:159)
                 at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
                 at org.ajax4jsf.application.AjaxViewHandler.restoreView(AjaxViewHandler.java:159)
                 at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:141)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                 at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:143)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                 at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                 at java.lang.Thread.run(Thread.java:619)
                


                • 5. Re: PortletBridge: Facelets not working
                  Jing Fu Newbie

                  Thanks for the hint, ebephil. I simplified my portlet with only one <rich:simpleTogglePanel> tag in a single xhtml page, but still no ui compsition can display. I will try to open a new thread to see any ideas.

                  • 6. Re: PortletBridge: Facelets not working
                    Jing Fu Newbie

                    Also Phil, I know you have your deadlines and projects, and I am almost still wondering if it is possbile for you to post a very simple portlet WAR that uses the portletbridge 3.1.3 GA or higher.

                    We have been trying to apply Liferay portal+ JSF + Richfaces + facelets into deliverables , and have been struggling with porlet bridge issues. It took us quiet a while to get the old portlet bridge to work , except the scope issue with JSF compoenents, so now we really want to give this new porlet bridge a try. But no luck yet.

                    Anyway I also opened a new thread with our settings and issues, if you may find 5 minutes at your disposal at some point:)
                    http://www.jboss.com/index.html?module=bb&op=viewtopic&t=127396

                    Thanks,
                    Jing