其实Teeda还支持HTML模板。
建立工程如下图:
所需lib列表如下:
aopalliance-1.0.jar
commons-collections-3.1.jar
commons-el-1.0.jar
commons-fileupload-1.2.jar
commons-io-1.3.2.jar
commons-lang-2.1.jar
commons-logging-1.1.jar
geronimo-jta_1.1_spec-1.0.jar
javassist-3.4.ga.jar
jcaptcha-all-1.0-RC6.jar
jstl-1.1.2.jar
log4j-1.2.13.jar
ognl-2.6.9-patch-20070908.jar
poi-3.0-FINAL.jar
portlet-api-1.0.jar
s2-extension-2.4.28.jar
s2-framework-2.4.28.jar
s2-tiger-2.4.28.jar
teeda-ajax-1.0.13-sp4.jar
teeda-tiger-1.0.13-sp4.jar
xercesImpl-2.6.2.jar
xmlParserAPIs-2.6.2.jar
teeda-core-1.0.13-sp4.jar
teeda-extension-1.0.13-sp4.jar
代码依次为:
HogeOutputRenderer.java
packagecom.teeda.render;
importjava.io.IOException;
importjavax.faces.component.html.HtmlOutputText;
importjavax.faces.context.FacesContext;
importorg.seasar.teeda.extension.render.html.THtmlOutputTextRenderer;
publicclassHogeOutputRendererextendsTHtmlOutputTextRenderer{
publicHogeOutputRenderer(){
System.out.println("hogehoge");
}
protectedvoidencodeHtmlOutputTextEnd(FacesContextarg0,
HtmlOutputTextarg1)throwsIOException{
System.out.println("encodeHtmlOutputTextEnd");
super.encodeHtmlOutputTextEnd(arg0,arg1);
}
}
AddPage.java
packagecom.teeda.web.add;
importorg.seasar.teeda.extension.annotation.validator.GreaterThanConstant;
publicclassAddPage{
@GreaterThanConstant
privateintarg1;
@GreaterThanConstant
privateintarg2;
privateintresult;
publicvoidinitialize(){
System.out.println("addinit");
}
publicvoidprerender(){
System.out.println("addprerender");
}
publicintgetArg1(){
returnarg1;
}
publicvoidsetArg1(intarg1){
this.arg1=arg1;
}
publicintgetArg2(){
returnarg2;
}
publicvoidsetArg2(intarg2){
this.arg2=arg2;
}
publicintgetResult(){
returnresult;
}
publicvoidsetResult(intresult){
this.result=result;
}
publicStringdoOnceCalculate(){
result=arg1+arg2;
returnnull;
}
publicbooleanisArg1Disabled(){
returnfalse;
}
}
HelloPage.java
packagecom.teeda.web.hello;
publicclassHelloPage{
publicStringhoge="Teeda";
publicClass<?>initialize(){
returnnull;
}
publicClass<?>prerender(){
returnnull;
}
publicStringgetLayout(){
returnnull;
}
}
app_aop.dicon
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
"http://www.seasar.org/dtd/components24.dtd">
<componentsnamespace="app_aop">
<includepath="convention.dicon"/>
<componentname="actionSupportInterceptor"class="org.seasar.teeda.extension.interceptor.ActionSupportInterceptor"/>
</components>
app.dicon
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
"http://www.seasar.org/dtd/components24.dtd">
<components>
<includepath="convention.dicon"/>
<includepath="aop.dicon"/>
<includepath="app_aop.dicon"/>
<includepath="teedaExtension.dicon"/>
</components>
appMessages_ja.properties与appMessages.properties暂为空。
convention.dicon
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
"http://www.seasar.org/dtd/components24.dtd">
<components>
<componentclass="org.seasar.framework.convention.impl.NamingConventionImpl">
<initMethodname="addRootPackageName">
<arg>"com.teeda"</arg>
</initMethod>
</component>
</components>
creator.dicon
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
"http://www.seasar.org/dtd/components24.dtd">
<components>
<includepath="convention.dicon"/>
<includepath="customizer.dicon"/>
<componentclass="org.seasar.framework.container.creator.ActionCreator"/>
<componentclass="org.seasar.framework.container.creator.DaoCreator"/>
<componentclass="org.seasar.framework.container.creator.DtoCreator"/>
<componentclass="org.seasar.framework.container.creator.DxoCreator"/>
<componentclass="org.seasar.framework.container.creator.HelperCreator"/>
<componentclass="org.seasar.framework.container.creator.LogicCreator"/>
<componentclass="org.seasar.framework.container.creator.PageCreator"/>
<componentclass="org.seasar.framework.container.creator.ServiceCreator"/>
<componentclass="org.seasar.framework.container.creator.InterceptorCreator"/>
<componentclass="org.seasar.framework.container.creator.ValidatorCreator"/>
<componentclass="org.seasar.framework.container.creator.ConverterCreator"/>
</components>
customizer.dicon
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
"http://www.seasar.org/dtd/components24.dtd">
<components>
<includepath="default-customizer.dicon"/>
<componentname="commandAspectCustomizer"class="org.seasar.framework.container.customizer.AspectCustomizer">
<propertyname="interceptorName">"aop.classLoaderAwareTraceInterceptor"</property>
<propertyname="pointcut">"do.*,initialize,prerender"</property>
</component>
<componentname="actionSupportAspectCustomizer"class="org.seasar.framework.container.customizer.AspectCustomizer">
<propertyname="interceptorName">"app_aop.actionSupportInterceptor"</property>
<propertyname="pointcut">"do.*,initialize,prerender"</property>
</component>
<componentname="actionCustomizer"class="org.seasar.framework.container.customizer.CustomizerChain">
<initMethodname="addCustomizer">
<arg>commandAspectCustomizer</arg>
</initMethod>
<initMethodname="addCustomizer">
<arg>actionSupportAspectCustomizer</arg>
</initMethod>
</component>
</components>
env.txt
ct
log4j.properties
log4j.category.org.seasar=DEBUG,C
log4j.additivity.org.seasar=false
log4j.category.examples=DEBUG,C
log4j.additivity.examples=false
log4j.appender.C=org.apache.log4j.ConsoleAppender
log4j.appender.C.Target=System.out
log4j.appender.C.ImmediateFlush=true
log4j.appender.C.layout=org.apache.log4j.PatternLayout
log4j.appender.C.layout.ConversionPattern=%-5p%d[%t]%m%n
log4j.rootLogger=INFO,A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d[%t]%-5p%c-%m%n
s2container.dicon
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
"http://www.seasar.org/dtd/components24.dtd">
<components>
<includecondition="#ENV=='ut'"path="warmdeploy.dicon"/>
<includecondition="#ENV=='ct'"path="hotdeploy.dicon"/>
<includecondition="#ENV!='ut'and#ENV!='ct'"path="cooldeploy.dicon"/>
</components>
teedaCustomize.dicon
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container2.4//EN"
"http://www.seasar.org/dtd/components24.dtd">
<components>
<componentclass="org.seasar.teeda.core.render.DefaultComponentIdLookupStrategy">
<propertyname="cooperateWithForeach">true</property>
</component>
<!--JSF標準のIDの採番方式にしなくてはいけない場合は下記を使用。-->
<!--
<componentclass="org.seasar.teeda.core.render.JsfSpecComponentIdLookupStrategy"/>
-->
<componentclass="org.seasar.teeda.core.application.impl.DefaultComponentLookupStrategy"/>
<componentclass="org.seasar.teeda.extension.util.TreeNavigationImageLocatorImpl">
<propertyname="imageRoot">"/img/"</property>
</component>
<componentclass="org.seasar.teeda.core.util.DefaultCancelHandler">
<initMethodname="addCancellableException">
<arg>@java.net.SocketException@class</arg>
</initMethod>
</component>
<componentclass="org.seasar.teeda.extension.util.TeedaExtensionConfiguration">
<!--outputTextを<span>要素の場合のみ関連づける(1.0.12互換)には以下のプロパティをtrueに設定-->
<propertyname="outputTextSpanOnly">false</property>
<!--<spanid="~Label">が<a>の子要素の場合のみラベルに関連づける(1.0.12互換)には以下のプロパティをtrueに設定-->
<propertyname="outputTextLabelUnderAnchorOnly">false</property>
<!--<labelid="~">をoutputLabelに関連づけないようにするには以下のプロパティをtrueに設定-->
<propertyname="disableLabelFactory">false</property>
<!--itemsが空の場合でもforEachの指定された要素を出力する場合(Teeda1.0.13-sp1以前と互換)は以下のプロパティをtrueに設定-->
<propertyname="outputForEachIfEmptyItems">false</property>
</component>
</components>
viewaddadd.html
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"
xmlns:te="http://www.seasar.org/teeda/extension"
xmlns:h="http://java.sun.com/jsf/html"
xml:lang="ja"lang="ja">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"/>
<titleid="aaa">Add</title>
<style>
.onTeedaError{
background-color:#FFCCCC;
}
</style>
</head>
<body>
<formid="addForm"action="dummy.html">
<div>
<spanid="messages"></span>
</div>
<table>
<tr>
<td></td><td><inputtype="text"id="arg1"title="INPUT1"disabled="disabled"/></td>
<td><spanid="arg1Message"></span></td>
</tr>
<tr>
<td>+</td>
<td><inputtype="text"id="arg2"title="INPUT2"/></td>
<td><spanid="arg2Message"></span></td>
</tr>
<tr>
<td>=</td>
<td><spanid="result"></span></td>
</tr>
</table>
<inputtype="submit"value="calculate"id="doOnceCalculate"te:renderJs="true"/>
</form>
</body>
</html>
viewhellohello.html
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="ja"lang="ja">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"/>
<title>TeedaExtensionsamples</title>
</head>
<body>
<formid="startForm">
<spanid="hoge">hoge</span>
</form>
</body>
</html>
faces-config.xml
<?xmlversion="1.0"?>
<!DOCTYPEfaces-configPUBLIC
"-//SunMicrosystems,Inc.//DTDJavaServerFacesConfig1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
<application>
<message-bundle>appMessages</message-bundle>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>ja</supported-locale>
</locale-config>
</application>
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>org.seasar.teeda.extension.HtmlOutputText</renderer-type>
<renderer-class>
com.teeda.render.HogeOutputRenderer
</renderer-class>
</renderer>
</render-kit>
</faces-config>
web.xml
<?xmlversion="1.0"?>
<!DOCTYPEweb-appPUBLIC
"-//SunMicrosystems,Inc.//DTDWebApplication2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.html</param-value>
</context-param>
<context-param>
<param-name>teeda.JAVASCRIPT_NOT_PERMITTED_PATH</param-name>
<param-value>/view/</param-value>
</context-param>
<filter>
<filter-name>extensionfilter</filter-name>
<filter-class>org.seasar.teeda.extension.filter.ExtensionFilter</filter-class>
</filter>
<filter>
<filter-name>encodingfilter</filter-name>
<filter-class>org.seasar.extension.filter.EncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter>
<filter-name>s2filter</filter-name>
<filter-class>org.seasar.framework.container.filter.S2ContainerFilter</filter-class>
</filter>
<filter>
<filter-name>hotdeployfilter</filter-name>
<filter-class>org.seasar.framework.container.hotdeploy.HotdeployFilter</filter-class>
</filter>
<filter>
<filter-name>requestDumpFilter</filter-name>
<filter-class>org.seasar.teeda.core.filter.RequestDumpFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>extensionfilter</filter-name>
<url-pattern>/teedaExtension/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>encodingfilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>s2filter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>hotdeployfilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>requestDumpFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>teedaServlet</servlet-name>
<servlet-class>org.seasar.teeda.core.webapp.TeedaServlet</servlet-class>
<init-param>
<param-name>configPath</param-name>
<param-value>app.dicon</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>facesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>facesServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>teedaServlet</servlet-name>
<url-pattern>/teedaServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/debug/debug.jsp</location>
</error-page>
</web-app>
index.jsp
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"/>
<title>Teedahtmlexample</title>
</head>
<body>
<ul>
<li>
<ahref="./view/hello/hello.html">Hello</a>
</li>
<li>
<ahref="./view/add/add.html">Add</a>
</li>
</ul>
</body>
</html>
上例实现了helloworld示例以及一个简单的加法演示程序。
请注意:
1.teedaCustomize.dicon配置文件是必须的,否则运行期会报一些很奇怪的错误。
2.在这个框架下路径名和Java文件名是有规定的。
譬如加法演示程序add:
在convention.dicon中设置RootPackageName后,必须在这个路径下的web目录下add子目录下新建AddPage.java文件。对于view层,静态的html所处的是viewaddadd.html,前后必须对应起来。
3.这个框架在性能上似乎仍有很长的路要走。