2 Replies Latest reply on May 28, 2007 5:30 PM by javabr

    richfaces + adf faces + myFaces + facelets

    yaapu

      Hi all,
      I'm trying to integrate the following tecnologies:

      - JBoss RichFaces 3.0.0
      - Oracle ADF Faces 10.1.3.4
      - Apache MyFaces 1.1.5
      - Facelets 1.1.11

      running on Tomcat 5.5.17

      Pages using the ajax4jsf framework alone seem to work just fine, but those requiring external resources such as the richfaces ones do not render as expected. The ADF faces renderkit appears to be in the way and the richfaces skins do not get passed via the richfaces CSS serving. I thought as a workaround to generate the css files myself and statically include them but there might be a smarter way ;-)

      As an example when loading the following page the rich:suggestionbox is rendered without any styles applied to it, it appears that the ADF Faces render kit is somehow in the way as one can tell from the tomcat console log

      <af:document xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:af="http://xmlns.oracle.com/adf/faces"
      xmlns:rich="http://richfaces.ajax4jsf.org/rich">
      <h:form>
      <h:inputText id="suggest" value="#{richFacesBean.text}"/>
      <rich:suggestionbox
      for="suggest"
      suggestionAction="#{richFacesBean.autocomplete}"
      var="item"
      <h:column>
      <h:outputText value="#{item.text}"/>
      </h:column>
      </rich:suggestionbox>
      </h:form>
      </af:document>


      I get on the tomcat console:

      ===================================================
      08/03 19:07:55 ERROR [Faces Servlet] - Servlet.service() for servlet Faces Servlet threw exception
      java.lang.NullPointerException
      at oracle.adfinternal.view.faces.renderkit.core.CoreRenderKit._addDebugResponseWriters(CoreRenderKit.java:420)
      at oracle.adfinternal.view.faces.renderkit.core.CoreRenderKit.createResponseWriter(CoreRenderKit.java:406)
      at org.ajax4jsf.framework.resource.TemplateCSSRenderer.send(TemplateCSSRenderer.java:74)
      at org.ajax4jsf.framework.resource.InternetResourceBase.send(InternetResourceBase.java:369)
      at org.ajax4jsf.framework.resource.ResourceLifecycle.send(ResourceLifecycle.java:86)
      at org.ajax4jsf.framework.resource.InternetResourceService.sendResource(InternetResourceService.java:213)
      at org.ajax4jsf.framework.resource.InternetResourceService.serviceResource(InternetResourceService.java:183)
      at org.ajax4jsf.framework.resource.InternetResourceService.serviceResource(InternetResourceService.java:118)
      at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:207)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:833)
      at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
      at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1285)
      at java.lang.Thread.run(Thread.java:595)

      My configuration is as following:

      **********************************************************
      * adf-faces-config.xml
      **********************************************************
      <?xml version="1.0"?>
      <adf-faces-config xmlns="http://xmlns.oracle.com/adf/view/faces/config">
      <debug-output>false</debug-output>
      <client-validation-disabled>true</client-validation-disabled>
      <skin-family>oracle</skin-family>
      </adf-faces-config>

      **********************************************************
      * faces-config.xml
      **********************************************************
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

      <faces-config >

      <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
      <locale-config>
      <default-locale>it</default-locale>
      <supported-locale>en</supported-locale>
      <supported-locale>it</supported-locale>
      </locale-config>
      <message-bundle>messages</message-bundle>



      <!-- Use the ADF RenderKit -->
      <default-render-kit-id>
      oracle.adf.core
      </default-render-kit-id>

      <!-- DEFAULT/SUPPORTED LOCALE/S FOR THE DEMO -->
      <locale-config>
      <default-locale>it</default-locale>
      <supported-locale>en</supported-locale>
      <supported-locale>it</supported-locale>
      </locale-config>


      <managed-bean>
      <managed-bean-name>richFacesBean</managed-bean-name>
      <managed-bean-class>test.RichFacesBean</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>
      </faces-config>


      **********************************************************
      * web.xml
      **********************************************************
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

      <!-- ============================ -->
      <!-- == SECTION: CONTEXT-PARAM == -->
      <!-- ============================ -->

      <!-- ADF faces -->
      <context-param>
      <param-name>oracle.adf.view.faces.ALTERNATE_VIEW_HANDLER</param-name>
      <param-value>com.sun.facelets.FaceletViewHandler</param-value>
      </context-param>
      <context-param>
      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
      <param-value>.jsp</param-value>
      </context-param>
      <context-param>
      <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
      <param-value>client</param-value>
      </context-param>
      <context-param>
      <param-name>oracle.adf.view.faces.USE_APPLICATION_VIEW_CACHE</param-name>
      <param-value>false</param-value>
      </context-param>
      <context-param>
      <param-name>oracle.adf.view.faces.CHECK_FILE_MODIFICATION</param-name>
      <param-value>true</param-value>
      </context-param>
      <context-param>
      <param-name>oracle.adf.view.faces.CHANGE_PERSISTENCE</param-name>
      <param-value>session</param-value>
      </context-param>

      <!-- MyFaces -->
      <context-param>
      <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
      <param-value>true</param-value>
      </context-param>
      <context-param>
      <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
      <param-value>false</param-value>
      </context-param>
      <context-param>
      <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
      <param-value>true</param-value>
      </context-param>
      <context-param>
      <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
      <param-value>true</param-value>
      </context-param>

      <!-- Facelets -->
      <context-param>
      <param-name>facelets.LIBRARIES</param-name>
      <param-value>/WEB-INF/tomahawk.taglib.xml;/WEB-INF/sandbox.taglib.xml</param-value>
      </context-param>
      <context-param>
      <param-name>facelets.VIEW_MAPPINGS</param-name>
      <param-value>*.xhtml</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.DEVELOPMENT</param-name>
      <param-value>true</param-value>
      </context-param>

      <!-- AJAX4JSF - RichFaces -->
      <context-param>
      <param-name>org.ajax4jsf.SKIN</param-name>
      <param-value>classic</param-value>
      </context-param>

      <!-- ====================== -->
      <!-- == SECTION: FILTERS == -->
      <!-- ====================== -->
      <!-- AJAX4JSF -->

      <display-name>Ajax4jsf Filter</display-name>
      <filter-name>ajax4jsf</filter-name>
      <filter-class>org.ajax4jsf.Filter</filter-class>

      <filter-mapping>
      <filter-name>ajax4jsf</filter-name>
      <servlet-name>Faces Servlet</servlet-name>
      REQUEST
      FORWARD
      INCLUDE
      </filter-mapping>

      <!-- ADF faces-->

      <filter-name>adfFaces</filter-name>
      <filter-class>oracle.adf.view.faces.webapp.AdfFacesFilter</filter-class>

      <filter-mapping>
      <filter-name>adfFaces</filter-name>
      <servlet-name>Faces Servlet</servlet-name>
      </filter-mapping>

      <!-- MyFaces -->

      <filter-name>MyFacesExtensionsFilter</filter-name>
      <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
      <init-param>
      <param-name>maxFileSize</param-name>
      <param-value>20m</param-value>
      </init-param>

      <filter-mapping>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <servlet-name>Faces Servlet</servlet-name>
      </filter-mapping>
      <filter-mapping>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
      </filter-mapping>
      <filter-mapping>
      <filter-name>MyFacesExtensionsFilter</filter-name>
      <url-pattern>*.faces</url-pattern>
      </filter-mapping>

      <!-- ====================== -->
      <!-- == SECTION: SERVLET == -->
      <!-- ====================== -->

      <!-- JSF Servlet -->

      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>


      <!-- ADF Servlet -->

      <servlet-name>resources</servlet-name>
      <servlet-class>oracle.adf.view.faces.webapp.ResourceServlet</servlet-class>


      <!-- ============================== -->
      <!-- == SECTION: SERVLET-MAPPING == -->
      <!-- ============================== -->

      <!-- JSF Servlet -->
      <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>/faces/*</url-pattern>
      </servlet-mapping>

      <!-- ADF Servlet -->
      <servlet-mapping>
      <servlet-name>resources</servlet-name>
      <url-pattern>/adf/*</url-pattern>
      </servlet-mapping>

      .... security stuff

      <!-- ======================== -->
      <!-- == SECTION: LISTENERS == -->
      <!-- ======================== -->

      <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>

      <!-- Spring support -->

      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

      </web-app>