myEclipse开发tapestry自定义组件:
1、新建web工程,添加tapestry框架
2、在src中新建一个package(取名mylib)
3、建立一个页面模板文件(Copyright.html):
<hr>
Copyright 2005. Foo Inc. All rights reserved.
4、建立Copyright.jwc文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<component-specification class="org.apache.tapestry.BaseComponent">
</component-specification>
5、建立.library文件(mylib.library):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<library-specification>
<component-type type="copyright"
specification-path="Copyright.jwc"/>
</library-specification>
type是希望在html页面中使用的组件名,specification-path指定.jwc文件。
6、在WEB-INF下面的.application文件中注册.library文件
<library id="mylib" specification-path="/mylib/mylib.library" />
id是使用自定义组件时的前缀。
7、在页面中使用自定义组件
<span jwcid="@mylib:copyright" />