天天看点

Tapestry5自定义组件

一、普通组件

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>