追忆Tapstry4.0------学习笔记(三)

接上例:http://blog.csdn.net/kunshan_shenbin/archive/2008/11/18/3325296.aspx

同讨论T3时一样,这里也该谈谈T4的布局管理。

T3版本参考:http://blog.csdn.net/kunshan_shenbin/archive/2008/11/14/3300058.aspx

如下图所示建立工程:

所需Jar包同上例一致。

代码如下:

Border.html

  1. <html>
  2. <head><title><span jwcid="@Insert" value="ognl:title"/></title></head>
  3. <body>
  4. <span jwcid="@RenderBlock" block="ognl:page.components.header"/>
  5. <table>
  6. <tr>
  7. <td width="40%">
  8.     <a href="" jwcid="@PageLink" page="Home"
  9.         disabled="ognl:page.pageName.equals('Home')">Home</a><br>
  10.     <a href="" jwcid="@PageLink" page="Products"
  11.         disabled="ognl:page.pageName.equals('Products')">Products</a><br>
  12.     <a href="" jwcid="@PageLink" page="Contact"
  13.         disabled="ognl:page.pageName.equals('Contact')">Contact</a>
  14. </td>
  15. <td>
  16. <span jwcid="@RenderBody">This is the page content.</span>
  17. </td>
  18. </tr>
  19. </table>
  20. </body>
  21. </html>

Border.jwc

  1. <?xml version="1.0"?>
  2. <!DOCTYPE component-specification PUBLIC
  3.   "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  4.   "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
  5. <component-specification>
  6.     <parameter name="title"/>
  7.     <parameter name="header"/>
  8. </component-specification>

Contact.html

  1. <html>
  2. <head><title>Contact</title></head>
  3. <body jwcid="$content$">
  4. <span jwcid="@Border" title="Contact">
  5. This is the Contact page.
  6. </span>
  7. </body>
  8. </html>

Contact.page

  1. <?xml version="1.0"?>
  2. <!DOCTYPE page-specification PUBLIC
  3.   "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  4.   "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
  5. <page-specification>
  6. </page-specification>

Home.html

  1. <html>
  2. <head><title>Home</title></head>
  3. <body jwcid="$content$">
  4. <span jwcid="header@Block"><h1>Home header</h1></span>
  5. <span jwcid="@Border" title="Home" header="ognl:components.header">
  6. This is the Home page.
  7. </span>
  8. </body>
  9. </html>

Home.page

  1. <?xml version="1.0"?>
  2. <!DOCTYPE page-specification PUBLIC
  3.   "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  4.   "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
  5. <page-specification>
  6. </page-specification>

Layout.application

  1. <!DOCTYPE application PUBLIC
  2.   "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  3.   "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
  4. <application name="Layout">
  5. </application>

Products.html

  1. <html>
  2. <head><title>Products</title></head>
  3. <body jwcid="$content$">
  4. <span jwcid="@Border" title="Products">
  5. This is the Products page.
  6. </span>
  7. </body>
  8. </html>

Products.page

  1. <?xml version="1.0"?>
  2. <!DOCTYPE page-specification PUBLIC
  3.   "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  4.   "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
  5. <page-specification>
  6. </page-specification>

web.xml

  1. <?xml version="1.0"?>
  2. <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  3.     xmlns:xsi="http://www.w3.org/TR/xmlschema-1/"
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
  5.     <display-name>Layout</display-name>
  6.     <servlet>
  7.         <servlet-name>Layout</servlet-name>
  8.         <servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class>
  9.         <load-on-startup>1</load-on-startup>
  10.     </servlet>
  11.     <servlet-mapping>
  12.         <servlet-name>Layout</servlet-name>
  13.         <url-pattern>/app</url-pattern>
  14.     </servlet-mapping>
  15. </web-app>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值