Also, if authentication was successful; that is, the value returned by the
Security.authenticate method was not null, we assign the returned User
object to the private class variable named user. The latter is marked as an
Application State Object, and so Tapestry creates a session and saves the object we
have assigned to user into it. If, however, authentication fails, no session is created.
At this point, you can run the application and see how it works. If you enter "user"
and "secret" for username and password, the ShowAll page should be shown, but if
either piece of information is wrong, or if you click the Or register link, you should
see the Registration page.
The Or register link is implemented as a PageLink component and doesn't
demonstrate anything new to us. However, if you have a look into the Tapestry 5
documentation for this component (http://tapestry.apache.org/tapestry5/
tapestry-core/component-parameters.html), you will notice that PageLink also
has a property named context. That property is not required but sometimes can be
quite useful.
Do you remember the discussion in Chapter 3 of different ways to pass information
when navigating between pages? One of the options was to use the page activation
context, and this is exactly the mechanism that can be used by PageLink if you
provide a value for its context property.
Pages:
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131