5.4. Page class

Registration.java. 

package devguide.personalizedwelcome;

import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.html.BasePage;

public abstract class Registration extends BasePage
{
    public abstract void setUser(User user);
    public abstract User getUser();
    
    public void register(IRequestCycle cycle) 1 
    {
        Registration welcome = (Registration) cycle.getPage("Welcome"); 2 
        
        welcome.setUser(getUser()); 3 
        
        cycle.activate(welcome); 4 
    }
}

1

The listener method.

[Important]Important
The signature of the listener methods have to match the pattern, public void listenerMethod(IRequestCycle cycle), or Tapestry will not recognize the method as a listener method.

2

cycle.getPage() retrieves the requested page object, Welcome, from the page pool.

[Note]Note
There is no URL or path involved in referencing pages, you simply reference them by their logical name as specified in the <application> specification.

Page objects are always of the type of their page class.

3

Copy the User in the Home page to the Welcome page before detaching the Home page from the request.

4

Activate the Welcome page. This will detach the Home page from the current request and attach to Welcome page instead.

User.java. 

package devguide.personalizedwelcome;

public class User
{
    private String _title;
    private String _firstName;
    private String _lastName;
    
    public String getFirstName()
    {
        return _firstName;
    }

    public String getLastName()
    {
        return _lastName;
    }

    public void setFirstName(String string)
    {
        _firstName = string;
    }

    public void setLastName(String string)
    {
        _lastName = string;
    }

    public String getTitle()
    {
        return _title;
    }

    public void setTitle(String string)
    {
        _title = string;
    }
}

User is a plain Javabeans class that is a model value object.