We have
to check whether there are enough words too.
The Foundations of Tapestry
[ 76 ]
Run the application, and you will see that the user is John Smith. The Start page
requested the User ASO, so it was created by Tapestry and saved into session with
default values in it.
Click on the Go to Another page link, and you will see that the same John Smith is
displayed there. Everything as expected. Return to the Start page.
Now enter some name into the text box, say, Jane Johnson, and click on the Submit
button. You will see the Another page, and the user displayed on it will be Jane
Johnson! If you remember, to set the new name, we have used the private field
named user in the Start page class, whereas the Another page uses its own private
field myUser to access the ASO. The fact that the Another page displays updated
information confirms that both private fields are connected to the same instance of
the ASO, no matter how they are named, as soon as they have the same type and
marked with the @ApplicationState annotation.
This convenient feature has one tricky consequence however. Let's say you have
created an ASO of type String on one of the pages:
@ApplicationState
private String someValue;
It worked fine for you, but later you decided that you need another ASO for a
different piece of information, and it will be a String too:
@ApplicationState
private String someCompletelyDifferentValue;
However, this will not work in the way that you expected it to.
Pages:
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109