You asked for person 1.
Return
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- We need a doctype to allow us to use special characters like
We use a "strict" DTD to make IE follow the alignment rules. -->
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd">
<body class="container">
<h3>Passing Data Between Pages: by Activation Context</h3>
<div class="eg">
<p>You asked for person ${personId}.</p>
<t:pagelink page="examples/state/PassingDataBetweenPages">Return</t:pagelink>
</div>
This page used the <strong>activation context</strong> to save its data through the redirection.
The data became part of the URL so the page can be bookmarked.<br/><br/>
This technique is usually employed to pass an <strong>identifier</strong>, eg. personId,
but it is not limited to one parameter (see the More Parameters and Variable Parameters examples).<br/><br/>
References:
<a href="http://tapestry.apache.org/page-navigation.html#PageNavigation-PageRenderRequests">Page Render Requests</a>.<br/><br/>
<t:pagelink page="Index">Home</t:pagelink><br/><br/>
<t:tabgroup>
<t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/state/PassingByActivationContext.tml"/>
<t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/state/PassingByActivationContext.java"/>
<t:sourcecodetab src="/web/src/main/resources/META-INF/assets/css/examples/olive.css"/>
</t:tabgroup>
</body>
</html>
package jumpstart.web.pages.examples.state;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Property;
/**
* This page demonstrates using the activation context to remember data through the redirect.
* The data will be appended to the page render request URL.
*/
@Import(stylesheet="css/examples/olive.css")
public class PassingByActivationContext {
// The activation context
@Property
private long personId;
// The code
// set() is public so that other pages can use it to set up this page.
public void set(Long personId) {
this.personId = personId;
}
// onActivate() is called by Tapestry to pass in the activation context from the URL.
void onActivate(Long personId) {
this.personId = personId;
}
// onPassivate() is called by Tapestry to get the activation context to put in the URL.
// To return more than one parameter, use Long[], or List<Long>, or Object[], or List<Object>.
Long onPassivate() {
return personId;
}
}
.eg {
margin: 20px 0;
padding: 14px;
color: olive;
border: 1px solid #ddd;
border-radius: 6px;
-webkit-border-radius: 6px;
-mox-border-radius: 6px;
}