Activation Context (2)

You requested Person 1.

First Name
Last Name
East Coast
Start Date
Jun 19, 1952
Look at the URL of this page. It is the page render request from the PageLink, and the activation context is at the end.

This page handles the activate event like this:

	void onActivate(Long personId) {
		this.personId = personId;

The method receives the activation context into personId.

References: PageLink, Page Render Requests, Page Activation.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<!-- We need a doctype to allow us to use special characters like &nbsp; 
     We use a "strict" DTD to make IE follow the alignment rules. -->
<html xmlns:t="">
<body class="container">
    <h3>Activation Context (2)</h3>
    <div class="eg">
        <p>You requested Person <em>${personId}</em>.</p>
        <t:beandisplay object="person"/>
        <t:pagelink t:page="examples/navigation/ActivationContext1">Return</t:pagelink>

    Look at the URL of this page. 
    It is the page render request from the PageLink, and the <strong>activation context</strong> is at the end.<br/><br/>
    This page handles the <em>activate</em> event like this:<br/><br/>
    void onActivate(Long personId) {
        this.personId = personId;
    The method receives the activation context into <code>personId</code>.<br/><br/>

    <a href="">PageLink</a>, 
    <a href="">Page Render Requests</a>, 
    <a href="">Page Activation</a>.<br/><br/>

    <t:pagelink t:page="Index">Home</t:pagelink><br/><br/>

        <t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/navigation/ActivationContext2.tml"/>
        <t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/navigation/"/>
        <t:sourcecodetab src="/web/src/main/resources/META-INF/assets/css/examples/plain.css"/>
        <t:sourcecodetab src="/business/src/main/java/jumpstart/business/domain/person/"/>
        <t:sourcecodetab src="/business/src/main/java/jumpstart/business/domain/person/"/>

package jumpstart.web.pages.examples.navigation;

import javax.ejb.EJB;


import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Property;

@Import(stylesheet = "css/examples/plain.css")
public class ActivationContext2 {

    // The activation context

    private Long personId;

    // Screen fields

    private Person person;

    // Generally useful bits and pieces

    private IPersonFinderServiceLocal personFinderService;

    // The code

    // onActivate() is called by Tapestry to pass in the activation context from the URL.

    void onActivate(Long personId) {
        this.personId = personId;

    // setupRender() is called by tapestry at the start of rendering - it's good for things that are display only.

    void setupRender() throws Exception {
        // Get person - ask business service to find it (from the database)
        person = personFinderService.findPerson(personId);

        if (person == null) {
            throw new Exception("Database data has not been set up!");

.eg {
                margin: 20px 0;
                padding: 14px;
                border: 1px solid #ddd;
                border-radius: 6px;
                -webkit-border-radius: 6px;
                -mox-border-radius: 6px;


import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

 * The Person entity.
public class Person implements Serializable {

    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(nullable = false)
    private Long id;

    @Column(nullable = false)
    private Integer version;

    @Column(length = 10, nullable = false)
    @Size(max = 10)
    private String firstName;

    @Column(length = 10, nullable = false)
    @Size(max = 10)
    private String lastName;
    private Regions region;

    private Date startDate;

    public String toString() {
        final String DIVIDER = ", ";
        StringBuilder buf = new StringBuilder();
        buf.append(this.getClass().getSimpleName() + ": ");
        buf.append("id=" + id + DIVIDER);
        buf.append("version=" + version + DIVIDER);
        buf.append("firstName=" + firstName + DIVIDER);
        buf.append("lastName=" + lastName + DIVIDER);
        buf.append("region=" + region + DIVIDER);
        buf.append("startDate=" + startDate);
        return buf.toString();

    // Default constructor is required by JPA.
    public Person() {

    public Person(String firstName, String lastName, Regions region, Date startDate) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.region = region;
        this.startDate = startDate;

    // The need for an equals() method is discussed at
    public boolean equals(Object obj) {
        return (obj == this) || (obj instanceof Person) && id != null && id.equals(((Person) obj).getId());

    // The need for a hashCode() method is discussed at

    public int hashCode() {
        return id == null ? super.hashCode() : id.hashCode();

    public void validate() throws ValidationException {


    public Long getId() {
        return id;

    public Integer getVersion() {
        return version;

    public void setVersion(Integer version) {
        this.version = version;

    public String getFirstName() {
        return firstName;

    public void setFirstName(String firstName) {
        this.firstName = firstName;

    public String getLastName() {
        return lastName;

    public void setLastName(String lastName) {
        this.lastName = lastName;

    public Regions getRegion() {
        return region;

    public void setRegion(Regions region) {
        this.region = region;

    public Date getStartDate() {
        return startDate;

    public void setStartDate(Date startDate) {
        this.startDate = startDate;



public enum Regions {