This is a very simple approach, but it
has some downsides.
We can use page activation context. This is a superior approach, but not for
every case, and it involves more coding.
Let's try both the approaches and see which one we will prefer for our application.
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;
??? ???
Chapter 3
[ 65 ]
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.
Pages:
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94