安裝和配置
目標
不使用XML
盡量減少冗餘
最大限度的使用命名標準
使用“系統”變數
Configuring the J2EE application
1.定義應用程式的根目錄(root package)
<context-param>
<param-name>tapestry.app-package</param-name>
<param-value>net.atos.mm.formation.tapestry</param-value>
</context-param>
2. 定義Tapestry filter
說明:filter-name也是應用程式名稱字
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
目錄結構
目錄結構推薦使用WTP項目結構
兩個資來源目錄
"src/main/java" 目錄存放所有應用程式的java檔案
"src/main/resources"目錄存放應用程式套件組合含的所有資源檔(*.tml html 模板 內嵌資源檔等)
在web文檔的根目錄下放置一個static檔案夾用來存放應用的所有純靜態檔案。比如 css js檔案 圖片等。
建立的根目錄後加入如下子目錄
“root.package”.pages 存放應用的所有頁面(java檔案 * .Tml html 模板)
“root.package”.components 存放使用者定義組件
“root.package”.mixins 存放一些能自訂行為(behaviours)的組件
“root.package”.base 存放一些不能直接使用的基礎組件
“root.package”.data convention, not mandatory(這裡不太理解)
“root.package”.services 存放使用者服務
在“root.package”.services中加入 AppModule來配置你的應用程式。
AppModule檔案
通過預先定義的方法可以轉載和配置你的應用程式。
可以裝在第三方的組件類庫
“App”代表應用程式的名字,在我們定義 tapestry-filter的時候也使用這個名字
例如我們建立應用程式的目錄結構如下:"net.atos.mm.formation.tapestry" filter命名為TapestryApp 那麼系統會預設尋找
"net.atos.mm.formation.tapestry.services.TapestryAppModule"這個設定檔
<< contributeApplicationDefaults >> 方法允許我們給些參數的調用
<< ApplicationDefaults >> 服務。例如:
tapestry.start-page-name : 應用的預設頁面
tapestry.supported-locales : 用逗號分割的locales支援
tapestry.file-check-interval : 檔案系統修改檢查的間隔時間
更多的詳細資料查看
http://tapestry.apache.org/tapestry5/tapestry-core/guide/conf.html
tapestry的目錄結構我們可以自己手工建立。也可以使用quickstart
http://tapestry.apache.org/tapestry5/quickstart/,利用maven可以很輕鬆的下載到tapestry的官方目錄結構,省去很多麻煩。