一、普通元件
1.java檔案
2.NavBar.tml
<table class="navigation" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<tr>
<t:loop source="pageNames" value="pageAttr">
<td class="${tabClass}">
[<t:pagelink page="${pageAttr.url}">${pageAttr.name}</t:pagelink>]
</td>
</t:loop>
</tr>
</table>
3.頁面使用
二、布局模闆元件
1.java檔案
2.tml檔案
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head>
<title>Tapestry 5 Demo Application</title>
<style type="text/css">
@import url(${asset:context:styles/myapp.css});
</style>
</head>
<body>
<div id="header">
<h1>Tapestry 5 Demo</h1>
<div id="navigator" style="float:right;margin-right:10px;">[<t:pagelink t:page="Index">首頁</t:pagelink>]</div>
</div>
<div id="container">
<t:body/>
</div>
<div id="footer">
Design by <a href="#" target="_blank" rel="external nofollow" >XXX Design</a>
</div>
</body>
</html>
3.layout.css
4.使用模闆
<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<p> 現在是: ${currentTime}. </p>
[<t:pagelink t:page="Index">refresh</t:pagelink>]
</p>
</t:layout>