Book Image

Tapestry 5: Building Web Applications

Book Image

Tapestry 5: Building Web Applications

Overview of this book

Table of Contents (17 chapters)
Tapestry 5
Credits
About the Author
About the Reviewers
Preface
Foreword
Where to Go Next

Passing a Value Between Pages


Let's say we want the Another page to display the message we entered at the Start page. First of all, we need to provide a property to store the passed value. Modify the Another page class (Another.java file) to look similar to this:

package com.packtpub.t5first.pages;
public class Another
{
private String passedMessage;
public String getPassedMessage()
{
return passedMessage;
}
public void setPassedMessage(String passedMessage)
{
this.passedMessage = passedMessage;
}
}

Next, let's use an expansion to display the passed message at the Another page. Modify the Another page template to look like this:

<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>
&lt...