RichFaces和facelets组合不起作用

时间:2015-03-19 08:27:54

标签: jsf jsf-2 richfaces facelets

我正在使用RichFaces和jsf 2.但是当我转移到facelets时         丰富的组件对我不起作用。我正在使用

  • richfaces-api-3.3.4.Final.jar,
  • RichFaces的-IMPL-jsf2-3.3.4.Final.jar,
  • RichFaces的-UI-3.3.4.Final.jar。
  • tomcat版本是7.0.23
  • netbeans 7.3.1

我在web.xml中配置了以下详细信息

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

     <context-param>
       <param-name>javax.faces.PROJECT_STAGE</param-name>
       <param-value>Development</param-value>
   </context-param>

   <context-param>
    <param-name>
        facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE
    </param-name>
    <param-value>false</param-value>
  </context-param>

   <context-param>
    <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.xhtml</param-value>
 </context-param>

 <context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
 </context-param>

 <context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <param-value>blueSky</param-value>
 </context-param>
 <!-- Making the RichFaces skin spread to standard HTML controls -->
 <context-param>
    <param-name>org.richfaces.CONTROL_SKINNING</param-name>
    <param-value>enable</param-value>
</context-param>   

 <filter>
    <display-name>RichFaces Filter</display-name>
    <filter-name>richfaces</filter-name>
    <filter-class>org.ajax4jsf.Filter</filter-class>
 </filter>
 <filter-mapping>
    <filter-name>richfaces</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
 </filter-mapping>

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

 <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
 </servlet-mapping>
 <session-config>
    <session-timeout>
        30
    </session-timeout>
  </session-config>
   <welcome-file-list>
    <welcome-file>faces/index.xhtml</welcome-file>
  </welcome-file-list>
</web-app>

faces-config.xml中

  <application>
  <view-handler>org.ajax4jsf.application.AjaxViewHandler</view-handler>
  </application>

   index.xhtml

     <?xml version="1.0" encoding="UTF-8"?> 
      <!-- 
      To change this template, choose Tools | Templates 
      and open the template in the editor. 
      --> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
   <html xmlns="http://www.w3.org/1999/xhtml" 
   xmlns:h="http://java.sun.com/jsf/html" 
   xmlns:f="http://java.sun.com/jsf/core" 
   xmlns:a4j="http://richfaces.org/a4j" 
   xmlns:rich="http://richfaces.org/rich" 
   xmlns:ui="http://java.sun.com/jsf/facelets"> 

   <ui:composition>     
   <h:form id="studentFormId" binding="#{StudentDetail.initForm}"> 
        <rich:panel id="Student" > 
            <f:facet name="header"> 
                <h:outputText value="Student DOB" /> 
    <rich:calender/>
            </f:facet>
     </rich:panel>
     </h:form>
     </ui:composition>
     </html>

当我在clean之后部署并构建它时会显示以下错误。

SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.
    config.ConfigureListener java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: 

    CONFIGURATION FAILED! Must have aConstructor that takes in a ComponentConfig

at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:273)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:842)

Caused by: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Must have a Constructor that takes in a ComponentConfig at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:449) at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:214)
... 43 more
Caused by: javax.faces.view.facelets.FaceletException: Must have a Constructor that takes in a ComponentConfig
at com.sun.faces.facelets.tag.AbstractTagLibrary$UserComponentHandlerFactory.<init> (AbstractTagLibrary.java:330)
at com.sun.faces.facelets.tag.AbstractTagLibrary.addComponent(AbstractTagLibrary.java:558)
at com.sun.faces.facelets.tag.TagLibraryImpl.putComponent(TagLibraryImpl.java:114)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processComponent(FaceletTaglibConfigProcessor.java:588)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTags       (FaceletTaglibConfigProcessor.java:368)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTagLibrary(FaceletTaglibConfigProcessor.java:321)
at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:270)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:437)
... 44 more
Caused by: java.lang.NoSuchMethodException:org.richfaces.taglib.AjaxValidatorHandler.<init> (javax.faces.view.facelets.ComponentConfig)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)
at com.sun.faces.facelets.tag.AbstractTagLibrary$UserComponentHandlerFactory.<init>(AbstractTagLibrary.java:328)

... 51 more

有人能发现我在这里犯了什么错误吗?

1 个答案:

答案 0 :(得分:2)

RichFaces 3.x和JSF 2工作正常。我使用的是JSF 2.2和RichFaces 3.3.4.Final。

您需要禁用内置的JSF 2 facelets并添加对旧jsf-facelets 1.1.15的依赖(根据https://developer.jboss.org/wiki/RichFaces333andJSF20)。

但请注意,Mojarra在根据规范查找DISABLE_FACELET_JSF_VIEWHANDLER而不是javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER时会有bug