SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 95 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

Add the following snippet to the Start page class:
@ApplicationState
private User user;
public User getUser()
{
return user;
}
Also, to an Application State Object of the type User, we have provided a public
getter method so that the page template could access the ASO. Now let's display the
user information on the page. Add the following code to the Start page template:

The user is ${user.firstName} ${user.lastName}


Now let's make similar changes to the Another page. First of all, the ASO and the
getter method for it is:
@ApplicationState
private User myUser;
public User getMyUser()
{
return myUser;
}
Hey, but why does the property for the ASO have a different name here? It was just
user, and now it is myUser. Doesn't this mean that the two pages will have different
instances of the ASO? No it doesn't. Let's see how all this works.
Chapter 3
[ 75 ]
As soon as a private field of some type (User in our case) is marked with the
@ApplicationState annotation, and if any other private field of the same type is
also marked with @ApplicationState annotation, it will refer to the same instance
of the ASO, no matter how the field is named.
Another important detail to understand is that Tapestry will create an instance of the
ASO the first time we request it.


Pages:
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6