Prev | Current Page 121 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

So all we need to do in order to check whether a user was
authenticated is to check whether the User ASO exists. Add the following code to the
ShowAll page class:
@ApplicationState
private User user;
private boolean userExists;
Object onActivate()
{
if (!userExists) return Start.class;
return null;
}
Chapter 4
[ 95 ]
Everything is very simple. We are checking the value of the boolean variable
associated with the User ASO (and automatically set by Tapestry, as you remember).
If the ASO was ever created??”which means our user was successfully authenticated,
the method will return null, otherwise it will return the class for the Start page.
Here onActivate() works similar to an ordinary event handler, with the difference
being that it responds not to an event generated by the user but to a page rendering
life cycle event. Tapestry will find this method by name, and invoke it at an
appropriate time. And since the method is not void, Tapestry will treat the returned
value according to the rules for the values returned by an event handler as outlined
in the previous chapter.
Those rules say that if the returned value is null, Tapestry will display (or redisplay)
the same page.


Pages:
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
wyciągarki hotele londyn Wczasy nad morzem sklep modelarski Okna PCV Wrocław