English 中文(简体)
JSF2.0 + Richfaces + facelet 是正确的。
原标题:JSF2.0 + Richfaces + Facelet is correct?

I create simple project using the following environment. 1. Netbeans IDE6.9.1 (File->NewProject->Select JSF2.0 libraries)

  1. Tomcat 6.0.29

jars
1.Commons-beanutils-1.7.0.jar
2.commons-collections-3.2.jar
3.commons-digester-1.8.jar
4.commns-logging-1.0.4.jar
5.el-funstions.jar
6.jhighlight.jar
7.cssparser-0.9.5.jar
8.guava-r09.jar
9.sac-1.3.jar
10.richfaces-api-3.3.3.Final.jar
11.richfaces-impl-3.3.3.Final.jar

12.richfaces-ui-3.3.3Final.jar
13.jsf-facelets-1.1.15.B1.jar
14.JSF 2.0-jsf-api.jar
15.JSF2.0-jsf-impl.jar
16.JSTL 1.1-Standard.jar
17.JSTL 1.1- jstl.jar

网址:xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Production</param-value>
</context-param>
<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>/faces/*</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>
<!--Configuration for Richfaces-->

<context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <param-value>blueSky</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>
<!--End of the configuration part for Richfaces-->

 <!--Configuration for Facelets-->
<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.jsp</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>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>
<!--End of the configuration part for Facelets-->

 <!-- The following attribute facelet    -->
<context-param>
    <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
    <param-value>true</param-value>
</context-param>
<!-- End of The following attribute facelet    -->
</web-app>

face-config.xml

<?xml version= 1.0  encoding= UTF-8 ?>
<faces-config version="2.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-facesconfig_2_0.xsd">
<application>
    <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>
</faces-config>

指数。 xhtml file

<?xml version= 1.0  encoding="UTF-8 ?>
<!DOCTYPE html PUBLIC "-//W#C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/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:rich="http://richfaces.org/rich">
<h:body>
             Hello Facelet
             <h:outputText value="Sample output text"/>
             <rich:panel>
                   <f:facet name="header">
                          <h:outputText value="Sample Panel"/>
                    </f:facet>

                     <h:outputText value="Panel content added here"/>
              </rich:panel>
<h:body>
</html>

When i run my project, i got the following error. and also i don t know the above configuration and jars are correct ot not.

javax.servlet.ServletException: Illegal attempt to set ViewHandler after a response has been rendered.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
java.lang.IllegalStateException: Illegal attempt to set ViewHandler after a response has been rendered.
com.sun.faces.application.ApplicationImpl.setViewHandler(ApplicationImpl.java:562)
org.ajax4jsf.event.InitPhaseListener.beforePhase(InitPhaseListener.java:92)
 com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
 com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
 com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
 com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
 org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
 org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
 org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
 org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

Help me. Thanks in advance.

最佳回答

faces-config.xml上改变观点手稿

<application>
  <view-handler>org.ajax4jsf.application.AjaxViewHandler</view-handler>
</application>
问题回答

暂无回答




相关问题
MySQL like query runs extremly slow for 5000 records table

I have this issue on our production server. The application stack is, Java Web App on Tomcat 6.0.18 iBatis data access layer MySQL 5.0 database CentOS The system is deployed on virtual server having ...

Set the path of web app in META-INF/context.xml?

I m tryin to change the path of a deployed war file in Tomcat. Reading the documentation I can t figure out if this is possible without moving the context-file to the /conf directory. Is it possible ...

MySQL Connector/J Problem

So I ve been having issues with the MySQL Connector/J driver not correctly loading in a Java Web Start application that is running on Tomcat 6.0.20. I ve copied the MySQL connector JAR file into the ...

Can t connect to MySQL database from tomcat

Hey, I m getting this error: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. I m just ...

JNDI Names -- Is Prefix "jdbc/" needed?

What s up with JNDI names? I m trying to get a javax.sql.DataSource using the new annotations feature of Java 5. It s not working for me, so I want to ask... I have a in my web.xml, inside of it is ...

热门标签