jboss rich face3.3.3のJSF 2.0 hello world付きの構成例


jboss rich faceは3.3.3からJSF 2.0をサポートするがJSF 2に対してはサポートする.0の内蔵FACLETはサポートされていません.以下、JSF 2での使用方法を示す.0でrich faceを使用
まずwebを構成する.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">
	<!--    JSF 2.0      start-->
	   <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <!--    JSF           -->
    <context-param> 
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name> 
        <param-value>.xhtml</param-value> 
    </context-param> 
   
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    
	<!-- end -->
	<!--   JBOSS richface      start -->
	<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>
	
	 <!-- Turn off the VDL viewhandler with the following context-param in web.xml  
	         VDL(JSF2.0   FACLET)       ,     NoSuchMethod   .-->
	<context-param>
        <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
        <param-value>true</param-value>
    </context-param>
    
     <!--
    RichFaces              Facelet。          ,       faces-config.xml      Facelets   。  ,Facelets          com.sun.facelets.FaceletViewHandler。
     -->
    <context-param>
        <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
        <param-value>com.sun.facelets.FaceletViewHandler</param-value>
    </context-param>
	<!-- Defining and mapping the RichFaces filter -->
	<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 -->

<welcome-file-list>
	<welcome-file>hello.jsf</welcome-file>
</welcome-file-list>
</web-app>

次はfaces-config.xmlはhelloのmanagementbenを定義します
<?xml version="1.0"?>
<faces-config 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"
	version="2.0">
	<!-- Empty for now. Your entries will go here. But even if you have no entries 
		in faces-config.xml, you are required to have a valid faces-config.xml file 
		with legal start and end tags. From JSF 2.0 tutorial at http://www.coreservlets.com/JSF-Tutorial/jsf2/ -->
	<managed-bean>
		<managed-bean-name>hello</managed-bean-name>
		<managed-bean-class>com.richface.mbeans.HelloBean</managed-bean-class>
		<managed-bean-scope>request</managed-bean-scope>
	</managed-bean>
	<navigation-rule>
		<from-view-id>/hello.xhtml</from-view-id>
		<navigation-case>
			<to-view-id>/show.xhtml</to-view-id>
			<from-outcome>success</from-outcome>
		</navigation-case>

	</navigation-rule>
</faces-config>

JSFのページファイルhello.xhtmlは、その接尾辞xhtmlとwebの構成に対応しています.
 <!--    JSF           -->
    <context-param> 
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name> 
        <param-value>.xhtml</param-value> 
    </context-param> 

ページファイルを作成します
<?xml version='1.0' encoding='UTF-8' ?> 
 <!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:ui="http://java.sun.com/jsf/facelets"
	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"> 
	
	<head></head>
	<body>
	<h:form>
	<rich:calendar name="Calendar" id="CalendarID"
               value="#{hello.current}"> 
    </rich:calendar> 
    <h:commandButton value="submit" action="#{hello.sayHello}"></h:commandButton>
		</h:form>
	</body>
 </html>

次にmanagebeanのコードを記述します
package com.richface.mbeans;

import java.util.Date;

public class HelloBean {

	private Date current;
	/**
	 * @return the current
	 */
	public Date getCurrent() {
		return current;
	}
	/**
	 * @param current the current to set
	 */
	public void setCurrent(Date current) {
		this.current = current;
	}
	public String sayHello(){
		System.out.println("hello"+current.toLocaleString());
		return "success";
	}
}

最後にtomcatに配備すればOKです.