开发好控件的管理:
对于自己开发的控件,我们要把它管理起来,以便在以后的开发流程中使用,
我的在这里谈谈如何管理自己开发的控件的问题。具体的方法就是把它归档到一个library
里去。
比如我开发了一些控件,我就把它归档到一个叫Common.library的xml文档里去。
Common.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>
<!-- Library Section-->
<library id="contrib" specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
<library id="basic" specification-path="/com/ht/components/basic/Basic.library"/>
<!-- Add more libraries here.-->
<!-- End of Library Section-->
<component-type type="TabPanel" specification-path="tabpanel/TabPanel.jwc"/>
<component-type type="Border" specification-path="border/Border.jwc"/>
<component-type type="ToolItem" specification-path="toolbar/ToolItem.jwc"/>
<component-type type="ToolBar" specification-path="toolbar/ToolBar.jwc"/>
<component-type type="AnchorDirect" specification-path="tree/components/AnchorDirect.jwc"/>
<component-type type="TreeDataView" specification-path="tree/components/TreeDataView.jwc"/>
<component-type type="TreeHeaders" specification-path="tree/components/TreeHeaders.jwc"/>
<component-type type="TreeNodeView" specification-path="tree/components/TreeNodeView.jwc"/>
<component-type type="TreeView" specification-path="tree/components/TreeView.jwc"/>
<component-type type="FileList" specification-path="table/FileList.jwc"/>
<component-type type="WrapInsertText" specification-path="wraptext/WrapInsertText.jwc"/>
<component-type type="HighlightInsertText" specification-path="highlight/HighlightInsertText.jwc"/>
<component-type type="DefaultTableColumnComponent" specification-path="table/DefaultTableColumnComponent.jwc"/>
<component-type type="AlignRightTableColumnComponent" specification-path="table/AlignRightTableColumnComponent.jwc"/>
<component-type type="DefaultTableColumns" specification-path="table/DefaultTableColumns.jwc"/>
</library-specification>
<libray-specification>包含两种元素
一种是library<library id="contrib" specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
因为如果被归档的控件还引用到其他的被归档的控件(控件库),就必须在这里包含进来。
例外一种是
<component-type type="ToolBar" specification-path="toolbar/ToolBar.jwc"/>
就是被归档的控件项定义,这句我们应该有印象,这个控件就是我们前面讨论的ToolBar
注意这个specification-path是相对路径。
比如我的Common.library位于com.ht.components包内,而那个ToolBar.jwc位于com.ht.components.toolbar包内。
页面的开发:
我的Web Application只支持英语和简体中文,以开发Home页为例,我所需要新建的文件
为:
Home.java
Home.page
Home.properties
Home_zh_CN.properties
它们都位于com.ht.home包内,对应的目录为F:/myproject/TapestryExmaple/src/
com/ht/home
Home.html
它位于context下home目录内,对应的目录为F:/myproject/TapestryExmaple/context/home
我的例程为:
Home.java
package com.ht.home;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.tapestry.engine.AbstractEngine;
import org.apache.tapestry.html.BasePage;
import com.ht.web.PatientRecordBasePage;
import com.ht.web.PatientRecordEngine;
import com.ht.components.tabpanel.*;
/**
* @author Hery Tang
*
* Creation Date 2003-9-22
* Version 1.0
*/
public class Home extends PatientRecordBasePage {
public void logout() {
PatientRecordEngine engine = (PatientRecordEngine) getEngine();
engine.logout();
}
}
Home.page
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
" http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd>
<page-specification class="com.ht.home.Home">
<component id="border" type="common:Border">
<message-binding name="title" key="title"/>
<binding name="styleSheet" expression="assets.test"/>
</component>
<context-asset name="$template" path="home/Home.html"/>
<context-asset name="menuIcon" path="home/images/homeIcon.gif"/>
<context-asset name="test" path="home/css/test.css"/>
</page-specification>
Home_zh_CN.properties
menuText=首页
title=首页
actionListener.logout.menuText=注销
welcome=欢迎
welcomeDetail=欢迎使用web病历管理系统,这是一套基于网络的B/S结构的病历管理服务系统,功能新颖,界面友好,欢迎使用。
Home.properties
title=Home
menuText=Home
actionListener.logout.menuText=Logout
welcome=Welcome
welcomeDetail=Welcome to use Web Document Manage System.This system based on B/S network structure, it provides internal documents' management for your company. It's document directory organized as that: a department as a unit, departments can share documents each other. Meanwhile, it provides detailed document version control.
Home.html
<span jwcid="border">
<table align="center" width="100%" height="100">
<tr>
<!-- ========================== START MID COL ======================= -->
<td VALIGN="TOP" width='100%'>
<table width='100%' cellpadding='0' cellspacing='0' border='0'>
<tr>
<td width='10'><img src='home/images/pixel.gif' width='10' height='1' alt='-'></td>
<td width='100%'><img src='home/images/welcome_head_icon.gif' ALIGN="BOTTOM" WIDTH="16" HEIGHT="16" ALT="Welcome!"> <font class='h2' style='color: #080c77;'><span key="welcome">Welcome</span></font></td>
<td width='10'><img src='home/images/pixel.gif' width='10' height='1' alt='-'></td>
</tr>
<tr>
<td height='5' colspan='3' valign='top'><img src='home/images/head_home_line.gif' width='254' height='5' alt='-'></td>
</tr>
<tr>
<td height='5' colspan='3' bgcolor='#ffffff'><img src='home/images/pixel.gif' width='1' height='5' alt='-'></td>
</tr>
<tr>
<td width='10' bgcolor='#ffffff'><img src='home/images/pixel.gif' width='10' height='1' alt='-'></td>
<td width='100%' bgcolor='#ffffff'>
<span key="welcomeDetail">Welcome to use Web Document Manage System.This system based on B/S network structure, it provides internal documents' management for your company. It's document directory organized as that: a department as a unit, departments can share documents each other. Meanwhile, it provides detailed document version control.</span>
</td>
<td width='10' bgcolor='#ffffff'><img src='home/images/pixel.gif' width='10' height='1' alt='-'></td>
</tr>
<tr>
<td height='5' colspan='3' bgcolor='#ffffff'><img src='home/images/pixel.gif' width='1' height='5' alt='-'></td>
</tr>
</table>
</td>
</tr>
</table>
</span>
对于页面的开发,有几个值得讨论的问题,
一 框架化的页面怎么实现
这个很简单,你只要开发一个控件,预先定义好一个显示框架,我就是这么做的,我开发了一个叫Border的控件,然后把变动的显示作为Border可变的内容输出。
你看我的 Home.html,它被<span jwcid="border">**</span>所包围,我的Border控件负责
显示每页确定的内容,变动的则只在Border的一个预定的区域显示。
二 国际化怎么办
Tapestry国际化非常简单,例如英文我要显示welcome,中文显示欢迎
只须这样就行:
<span key="welcome">Welcome</span>(中间的Welcome是预览hmtl用的没有
别的意义),然后你在home.properties设定key-value对为: welcome=Welcome
在Home_zh_CN.properties设定为: welcome=欢迎,不过最后打包时你要将你的
Home_zh_CN.properties用jdk的bin目录下的native2ascii命令转化一下,不然会
显示成乱码。
我们来分析一下Home.page
<page-specification class="com.ht.home.Home">
声明本页对应的class为com.ht.home.Home
<component id="border" type="common:Border">
<message-binding name="title" key="title"/>
<binding name="styleSheet" expression="assets.test"/>
</component>
声明并配置一个Border类型的控件
<message-binding name="title" key="title"/>
指定了本页的title
binding name="styleSheet" expression="assets.test"/>
指定了本页应用的StyleSheet资源
<context-asset name="$template" path="home/Home.html"/>
指定了Home页的模版为home/Home.html
<context-asset name="menuIcon" path="home/images/homeIcon.gif"/>
声明一个context-asset(图标)
<context-asset name="test" path="home/css/test.css"/>
声明一个context-asset(Stylesheet),被上面的Border控件引用
最后讲讲划分子模块的问题:
比如我的Web Application包含两个子模快home, patientrecord,
home对应的包为com.ht.home,绝对路径为F:/myproject/TapestryExmaple/src/
com/ht/home,对应的context目录为home,绝对路径为F:/myproject/
TapestryExmaple/context/home
patientrecord对应的包为com.ht.patientrecord,绝对路径为F:/myproject/TapestryExmaple/src/com/ht/patientrecord,
对应的context目录为patientrecord,绝对路径为F:/myproject/
TapestryExmaple/context/patientrecord
home模块下的页面有
Home,Register,Login,About,PaitentRecordException,SecurityException
patientrecord模块下的页面有
Browser,Create,AddTreatment,AddExamination,AddOperation,AddOperationVisit,AddOperationVisit,AddComment
我需要将这些页面归档,所以对应home子模块有Home.libray,对应于patientrecord
有PatientRecord.library
Home.library的位于com.ht.home包下,
PatientRecord.library位于com.ht.patientrecord包下
他们分别为
Home.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>
<!-- Library Section-->
<library id="contrib" specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
<library id="common" specification-path="/com/ht/components/Common.library"/>
<!-- Add more libraries here.-->
<!-- End of Library Section-->
<page name="Home" specification-path="Home.page"/>
<page name="Register" specification-path="Register.page"/>
<page name="Login" specification-path="Login.page"/>
<page name="About" specification-path="About.page"/>
<page name="PaitentRecordException" specification-path="PRException.page"/>
<page name="SecurityException" specification-path="SecurityExceptionPage.page"/>
</library-specification>
PatientRecord.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>
<!-- Library Section-->
<library id="contrib" specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
<library id="common" specification-path="/com/ht/components/Common.library"/>
<!-- Add more libraries here.-->
<!-- End of Library Section-->
<page name="Browser" specification-path="Browser.page"/>
<page name="Create" specification-path="Create.page"/>
<page name="AddTreatment" specification-path="AddTreatment.page"/>
<page name="AddExamination" specification-path="AddExamination.page"/>
<page name="AddOperation" specification-path="AddOperation.page"/>
<page name="AddOperationVisit" specification-path="AddOperationVisit.page"/>
<page name="AddComment" specification-path="AddComment.page"/>
</library-specification>
最后我们再看一下patientrecord.application这个Tapestry Web 应用核心配置文件:
patientrecord.application
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
" http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd>
<application name="Patient Record System" engine-class="com.ht.web.PatientRecordEngine">
<property name="org.apache.tapestry.visit-class" value="com.ht.web.VisitorState"/>
<property name="com.ht.home-page" value="home:Home"/>
<!--<property name="com.ht.exception-page" value="home:PaitentRecordException"/>-->
<property name="com.ht.security-exception-page" value="home:SecurityExceptionPage"/>
<!--Overrided the Home Service to let us to decide which page will be the home page-->
<service name="home" class="com.ht.web.HomeService"/>
<library id="home" specification-path="/com/ht/home/Home.library"/>
<library id="patientrecord" specification-path="/com/ht/patientrecord/PatientRecord.library"/>
</application>
看看最后两行
<library id="home" specification-path="/com/ht/home/Home.library"/>
<library id="patientrecord" specification-path="/com/ht/patientrecord/PatientRecord.library"/>
我们把那两个libary文件包含进来了,分别对应id为home, patientrecord
,我们要在程序里激活Home页,则只需
得一个IRequestCycle对象cycle
cycle.activate("home:Home");
注意“home:Home“,前一个home是library name,后一个是Page name.这是Tapestry
自定义的名字访问法则。
以上,是我开发Tapestry Web Application的一点心得体会,欢迎讨论批评.
对于自己开发的控件,我们要把它管理起来,以便在以后的开发流程中使用,
我的在这里谈谈如何管理自己开发的控件的问题。具体的方法就是把它归档到一个library
里去。
比如我开发了一些控件,我就把它归档到一个叫Common.library的xml文档里去。
Common.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>
<!-- Library Section-->
<library id="contrib" specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
<library id="basic" specification-path="/com/ht/components/basic/Basic.library"/>
<!-- Add more libraries here.-->
<!-- End of Library Section-->
<component-type type="TabPanel" specification-path="tabpanel/TabPanel.jwc"/>
<component-type type="Border" specification-path="border/Border.jwc"/>
<component-type type="ToolItem" specification-path="toolbar/ToolItem.jwc"/>
<component-type type="ToolBar" specification-path="toolbar/ToolBar.jwc"/>
<component-type type="AnchorDirect" specification-path="tree/components/AnchorDirect.jwc"/>
<component-type type="TreeDataView" specification-path="tree/components/TreeDataView.jwc"/>
<component-type type="TreeHeaders" specification-path="tree/components/TreeHeaders.jwc"/>
<component-type type="TreeNodeView" specification-path="tree/components/TreeNodeView.jwc"/>
<component-type type="TreeView" specification-path="tree/components/TreeView.jwc"/>
<component-type type="FileList" specification-path="table/FileList.jwc"/>
<component-type type="WrapInsertText" specification-path="wraptext/WrapInsertText.jwc"/>
<component-type type="HighlightInsertText" specification-path="highlight/HighlightInsertText.jwc"/>
<component-type type="DefaultTableColumnComponent" specification-path="table/DefaultTableColumnComponent.jwc"/>
<component-type type="AlignRightTableColumnComponent" specification-path="table/AlignRightTableColumnComponent.jwc"/>
<component-type type="DefaultTableColumns" specification-path="table/DefaultTableColumns.jwc"/>
</library-specification>
<libray-specification>包含两种元素
一种是library<library id="contrib" specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
因为如果被归档的控件还引用到其他的被归档的控件(控件库),就必须在这里包含进来。
例外一种是
<component-type type="ToolBar" specification-path="toolbar/ToolBar.jwc"/>
就是被归档的控件项定义,这句我们应该有印象,这个控件就是我们前面讨论的ToolBar
注意这个specification-path是相对路径。
比如我的Common.library位于com.ht.components包内,而那个ToolBar.jwc位于com.ht.components.toolbar包内。
页面的开发:
我的Web Application只支持英语和简体中文,以开发Home页为例,我所需要新建的文件
为:
Home.java
Home.page
Home.properties
Home_zh_CN.properties
它们都位于com.ht.home包内,对应的目录为F:/myproject/TapestryExmaple/src/
com/ht/home
Home.html
它位于context下home目录内,对应的目录为F:/myproject/TapestryExmaple/context/home
我的例程为:
Home.java
package com.ht.home;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.tapestry.engine.AbstractEngine;
import org.apache.tapestry.html.BasePage;
import com.ht.web.PatientRecordBasePage;
import com.ht.web.PatientRecordEngine;
import com.ht.components.tabpanel.*;
/**
* @author Hery Tang
*
* Creation Date 2003-9-22
* Version 1.0
*/
public class Home extends PatientRecordBasePage {
public void logout() {
PatientRecordEngine engine = (PatientRecordEngine) getEngine();
engine.logout();
}
}
Home.page
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
" http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd>
<page-specification class="com.ht.home.Home">
<component id="border" type="common:Border">
<message-binding name="title" key="title"/>
<binding name="styleSheet" expression="assets.test"/>
</component>
<context-asset name="$template" path="home/Home.html"/>
<context-asset name="menuIcon" path="home/images/homeIcon.gif"/>
<context-asset name="test" path="home/css/test.css"/>
</page-specification>
Home_zh_CN.properties
menuText=首页
title=首页
actionListener.logout.menuText=注销
welcome=欢迎
welcomeDetail=欢迎使用web病历管理系统,这是一套基于网络的B/S结构的病历管理服务系统,功能新颖,界面友好,欢迎使用。
Home.properties
title=Home
menuText=Home
actionListener.logout.menuText=Logout
welcome=Welcome
welcomeDetail=Welcome to use Web Document Manage System.This system based on B/S network structure, it provides internal documents' management for your company. It's document directory organized as that: a department as a unit, departments can share documents each other. Meanwhile, it provides detailed document version control.
Home.html
<span jwcid="border">
<table align="center" width="100%" height="100">
<tr>
<!-- ========================== START MID COL ======================= -->
<td VALIGN="TOP" width='100%'>
<table width='100%' cellpadding='0' cellspacing='0' border='0'>
<tr>
<td width='10'><img src='home/images/pixel.gif' width='10' height='1' alt='-'></td>
<td width='100%'><img src='home/images/welcome_head_icon.gif' ALIGN="BOTTOM" WIDTH="16" HEIGHT="16" ALT="Welcome!"> <font class='h2' style='color: #080c77;'><span key="welcome">Welcome</span></font></td>
<td width='10'><img src='home/images/pixel.gif' width='10' height='1' alt='-'></td>
</tr>
<tr>
<td height='5' colspan='3' valign='top'><img src='home/images/head_home_line.gif' width='254' height='5' alt='-'></td>
</tr>
<tr>
<td height='5' colspan='3' bgcolor='#ffffff'><img src='home/images/pixel.gif' width='1' height='5' alt='-'></td>
</tr>
<tr>
<td width='10' bgcolor='#ffffff'><img src='home/images/pixel.gif' width='10' height='1' alt='-'></td>
<td width='100%' bgcolor='#ffffff'>
<span key="welcomeDetail">Welcome to use Web Document Manage System.This system based on B/S network structure, it provides internal documents' management for your company. It's document directory organized as that: a department as a unit, departments can share documents each other. Meanwhile, it provides detailed document version control.</span>
</td>
<td width='10' bgcolor='#ffffff'><img src='home/images/pixel.gif' width='10' height='1' alt='-'></td>
</tr>
<tr>
<td height='5' colspan='3' bgcolor='#ffffff'><img src='home/images/pixel.gif' width='1' height='5' alt='-'></td>
</tr>
</table>
</td>
</tr>
</table>
</span>
对于页面的开发,有几个值得讨论的问题,
一 框架化的页面怎么实现
这个很简单,你只要开发一个控件,预先定义好一个显示框架,我就是这么做的,我开发了一个叫Border的控件,然后把变动的显示作为Border可变的内容输出。
你看我的 Home.html,它被<span jwcid="border">**</span>所包围,我的Border控件负责
显示每页确定的内容,变动的则只在Border的一个预定的区域显示。
二 国际化怎么办
Tapestry国际化非常简单,例如英文我要显示welcome,中文显示欢迎
只须这样就行:
<span key="welcome">Welcome</span>(中间的Welcome是预览hmtl用的没有
别的意义),然后你在home.properties设定key-value对为: welcome=Welcome
在Home_zh_CN.properties设定为: welcome=欢迎,不过最后打包时你要将你的
Home_zh_CN.properties用jdk的bin目录下的native2ascii命令转化一下,不然会
显示成乱码。
我们来分析一下Home.page
<page-specification class="com.ht.home.Home">
声明本页对应的class为com.ht.home.Home
<component id="border" type="common:Border">
<message-binding name="title" key="title"/>
<binding name="styleSheet" expression="assets.test"/>
</component>
声明并配置一个Border类型的控件
<message-binding name="title" key="title"/>
指定了本页的title
binding name="styleSheet" expression="assets.test"/>
指定了本页应用的StyleSheet资源
<context-asset name="$template" path="home/Home.html"/>
指定了Home页的模版为home/Home.html
<context-asset name="menuIcon" path="home/images/homeIcon.gif"/>
声明一个context-asset(图标)
<context-asset name="test" path="home/css/test.css"/>
声明一个context-asset(Stylesheet),被上面的Border控件引用
最后讲讲划分子模块的问题:
比如我的Web Application包含两个子模快home, patientrecord,
home对应的包为com.ht.home,绝对路径为F:/myproject/TapestryExmaple/src/
com/ht/home,对应的context目录为home,绝对路径为F:/myproject/
TapestryExmaple/context/home
patientrecord对应的包为com.ht.patientrecord,绝对路径为F:/myproject/TapestryExmaple/src/com/ht/patientrecord,
对应的context目录为patientrecord,绝对路径为F:/myproject/
TapestryExmaple/context/patientrecord
home模块下的页面有
Home,Register,Login,About,PaitentRecordException,SecurityException
patientrecord模块下的页面有
Browser,Create,AddTreatment,AddExamination,AddOperation,AddOperationVisit,AddOperationVisit,AddComment
我需要将这些页面归档,所以对应home子模块有Home.libray,对应于patientrecord
有PatientRecord.library
Home.library的位于com.ht.home包下,
PatientRecord.library位于com.ht.patientrecord包下
他们分别为
Home.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>
<!-- Library Section-->
<library id="contrib" specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
<library id="common" specification-path="/com/ht/components/Common.library"/>
<!-- Add more libraries here.-->
<!-- End of Library Section-->
<page name="Home" specification-path="Home.page"/>
<page name="Register" specification-path="Register.page"/>
<page name="Login" specification-path="Login.page"/>
<page name="About" specification-path="About.page"/>
<page name="PaitentRecordException" specification-path="PRException.page"/>
<page name="SecurityException" specification-path="SecurityExceptionPage.page"/>
</library-specification>
PatientRecord.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>
<!-- Library Section-->
<library id="contrib" specification-path="/org/apache/tapestry/contrib/Contrib.library"/>
<library id="common" specification-path="/com/ht/components/Common.library"/>
<!-- Add more libraries here.-->
<!-- End of Library Section-->
<page name="Browser" specification-path="Browser.page"/>
<page name="Create" specification-path="Create.page"/>
<page name="AddTreatment" specification-path="AddTreatment.page"/>
<page name="AddExamination" specification-path="AddExamination.page"/>
<page name="AddOperation" specification-path="AddOperation.page"/>
<page name="AddOperationVisit" specification-path="AddOperationVisit.page"/>
<page name="AddComment" specification-path="AddComment.page"/>
</library-specification>
最后我们再看一下patientrecord.application这个Tapestry Web 应用核心配置文件:
patientrecord.application
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
" http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd>
<application name="Patient Record System" engine-class="com.ht.web.PatientRecordEngine">
<property name="org.apache.tapestry.visit-class" value="com.ht.web.VisitorState"/>
<property name="com.ht.home-page" value="home:Home"/>
<!--<property name="com.ht.exception-page" value="home:PaitentRecordException"/>-->
<property name="com.ht.security-exception-page" value="home:SecurityExceptionPage"/>
<!--Overrided the Home Service to let us to decide which page will be the home page-->
<service name="home" class="com.ht.web.HomeService"/>
<library id="home" specification-path="/com/ht/home/Home.library"/>
<library id="patientrecord" specification-path="/com/ht/patientrecord/PatientRecord.library"/>
</application>
看看最后两行
<library id="home" specification-path="/com/ht/home/Home.library"/>
<library id="patientrecord" specification-path="/com/ht/patientrecord/PatientRecord.library"/>
我们把那两个libary文件包含进来了,分别对应id为home, patientrecord
,我们要在程序里激活Home页,则只需
得一个IRequestCycle对象cycle
cycle.activate("home:Home");
注意“home:Home“,前一个home是library name,后一个是Page name.这是Tapestry
自定义的名字访问法则。
以上,是我开发Tapestry Web Application的一点心得体会,欢迎讨论批评.