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

Making a Page Field Persistent


We can simply tell Tapestry that we want it to remember the value we have set to a page field by using the @Persist annotation on that field. Let's try this and add the annotation to the Another page class:

@Persist
private String passedMessage;

If you run the application now, it will work perfectly well, and the Another page will successfully display the message we have passed to it. What a simple solution! However, there are two potential problems associated with it. To understand where they come from, let's see how property persistence is achieved in Tapestry.

To store the value we have assigned to a persistent property, Tapestry creates an HttpSession. HttpSession can be understood as a piece of memory on the server associated with a specific user. Web applications have a way of tracking users that came to them, and if they have a session for a particular user, they can store user specific details.

Back to our application, as soon as we have put some value...