随笔-112  评论-73  文章-0  trackbacks-0

Trinidad发布了1.2.1版本,针对JSF1.2实现的组件,下载了Example,将jsf-impl.jar和jsf-api.jar(是SUN对JSF1.2的实现)及其依赖包复制到WEB-INF/lib目录下即可运行了.

参照这个Example就可以创建自己的JSF应用了.

下面主要介绍一下trinidad 与facelets一起使用时我遇到的问题及解决方法:

主要是配置web.xml和faces-config.xml 可以参照https://facelets.dev.java.net/nonav/docs/dev/docbook.html#gettingstarted-setup-web这个文档来配置facelets,后面附有完整的配置好的代码。

需要注意的问题就是:

配置好的facelets后在faces-config.xml中有这样一段代码:

<application>
    <view-handler>
      com.sun.facelets.FaceletViewHandler
    </view-handler>    
</application> 
在加入trinidad后这部分变为
  <application>
<default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>

<locale-config>
<default-locale>cn</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
</application>
一定要将
    <view-handler>
      com.sun.facelets.FaceletViewHandler
    </view-handler>    
这段删除才可以显示出页面。要不然会提示一个错误:

java.lang.IllegalStateException: No RenderingContext
        at org.apache.myfaces.trinidad.render.CoreRenderer.encodeBegin(CoreRenderer.java:156)
        at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeBegin(UIXComponentBase.java:704)
        at org.apache.myfaces.trinidad.component.UIXComponentBase.__encodeRecursive(UIXComponentBase.java:1267)
        at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeAll(UIXComponentBase.java:757)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:890)
        at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:571)
        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:178)
        at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:171)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)


web.xml(已经配置好了JSF1.2(sun实现)\facelets\spring)
<?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">
<display-name>XiangYun</display-name>
<!-- ==========facelets =========== -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>2</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</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>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>
<!-- =============trinidad ============ -->
<context-param>
<param-name>org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.trinidad.CLIENT_STATE_METHOD</param-name>
<param-value>all</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.trinidad.CHANGE_PERSISTENCE</param-name>
<param-value>session</param-value>
</context-param>
<!--spring config file-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml /WEB-INF/beans.xml</param-value>
</context-param>
<!-- trinidad filter-->
<filter>
<filter-name>trinidad</filter-name>
<filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>trinidad</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<!-- faces servlet-->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- trinidad resource loader servlet -->
<servlet>
<servlet-name>resources</servlet-name>
<servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class>
</servlet>

<!-- spring servlet -->
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>resources</servlet-name>
<url-pattern>/adf/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>resources</servlet-name>
<url-pattern>*.source</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
 
face-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
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_1_2.xsd">
<navigation-rule>
<from-view-id>/welcome.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/pages/main.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>welcome</from-outcome>
<to-view-id>/welcome.xhtml</to-view-id>
</navigation-case>
</navigation-rule>

<application>
<default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
<!-- spring config -->
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
<locale-config>
<default-locale>cn</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
</application>
</faces-config>
 

Technorati : ,

posted on 2007-07-18 17:59 Libo 阅读(1561) 评论(1)  编辑  收藏

评论:
# re: facelets1.2 与 trinidad1.2.1 2007-07-18 22:54 | ginkgo
good blog.

btw.
myfaces 1.2 released.
  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: