Both Application
State Objects will refer to the same string, so as soon as you change the value of one
of them, the other one will return the same new value too.
The correct way to use an ASO is to package a number of related pieces of
information into a specially created purpose class, like User in our example. Of
course, if you know that there is already some class you can conveniently reuse, do
that. But remember, each ASO must have its own type, or it will be referring to some
other already existing ASO.
Was an ASO Already Instantiated?
The final important piece of knowledge about dealing with an ASO is checking
whether it exists or not. Consider the following scenario??”as soon as the user has
successfully logged in, you are storing his or her data in an ASO. On the other pages
you are going to check whether the user is logged in and change the displayed
information appropriately.
Chapter 3
[ 77 ]
Remember that Tapestry will always give you an ASO as soon as you request for
it. So you can request for the User ASO, check its contents, and if the contents are
default, then the user hasn't logged in yet. All this is fine; but the problem is that you
want to make your application highly scalable, which means you do not want to
create a session unless it is absolutely necessary.
Pages:
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110