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

Creating and Using an Application State Object


In Tapestry, an object that is made available for every page of the application is termed Application State Object (ASO). Usually, this is some kind of object we create specially for the purpose of storing some set of data in an organized way. Say, we can have a User class for storing information about the application's user. It can be as simple as this:

package com.packtpub.t5first.util;
public class User
{
private String firstName = "John";
private String lastName = "Smith";
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;
}
}

Note

Note that I have placed this class into com.packtpub.t5first.util package. Please remember that you should never place anything but page classes into the pages sub package (such as com.packtpub.t5first.pages in this...