学习一:前言也可以称作前戏

     Tapestry之前的概念,怎么建新工程,关于一些基础,就不说了,我是看的英文,觉得有些东西还不错,就直接照我的理解搞过来了。理解难免有偏差。

   这里涉及两个页面 start.tml & another.tml

   start.tml有一个currenttime,对应类中的getCurrentTime(); 有一个输入框 一个提交按钮,提交message的值到another.tml。还有一个链接,到another.tml。

start.tml

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">

<head>

<title>Tapestry Start Page</title>

</head>

<body>

<h1>Tapestry Start Page</h1>

<p> The current date and time is: ${currentTime}. </p>

<p> The same date and time in milliseconds is:

${currentTime.time}. </p>

<p> And here is the hash code for it:

${currentTime.hashCode()}. </p>

<p>

<t:PageLink t:page="Another">Go to Another

page</t:PageLink>

</p>

<p>Submit a message:</p>

<t:form t:id="userInputForm">

<t:textfield t:value="message"/>

<input type="submit" value="Submit"/>

</t:form>

</body>

</html>

Start.java

package com.packtpub.t5first.pages;

import java.util.Date;

import org.apache.tapestry.annotations.InjectPage;

import org.apache.tapestry.annotations.OnEvent;

/**

* Start page of application t5first.

*/

public class Start

{

private int someValue = 12345;

private String message="initial value";

@InjectPage

private Another another;

public int getSomeValue()

{

return someValue;

}

public void setSomeValue(int value)

{

this.someValue = value;

}

public Date getCurrentTime()

{

return new Date();

}

public String getMessage()

{

return message;

}

public void setMessage(String message)

{

System.out.println("Setting the message: " + message);

this.message = message;

}

@OnEvent(value="submit", component="userInputForm")

Object onFormSubmit()

{

System.out.println("Handling form submission!");

another.setPassedMessage(message);

return another;

}

}
another.tml
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">

<head>

<title>Another Page</title>

</head>

<body>

<h1>Another Page</h1>

<p>Received a new message: ${passedMessage}</p>

<p>

<t:PageLink t:page="Start">Back to the Start

page</t:PageLink>

</p>

</body>

</html>
 
Another.java
package com.packtpub.t5first.pages;

public class Another

{

private String passedMessage;

public String getPassedMessage()

{

return passedMessage;

}

public void setPassedMessage(String passedMessage)

{

this.passedMessage = passedMessage;

}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值