Add the onActivate method to the Details class with the following contents:
void onActivate(long id)
{
celebrity = dataSource.getCelebrityById(id);
}
Chapter 4
[ 105 ]
You will also need to provide access to the data source ASO and remove the
@Persistent attribute from the celebrity property:
@ApplicationState
private MockDataSource dataSource;
private Celebrity celebrity;
Finally, run the application and repeat the experiment. On the ShowAll page, click
on the last name of some celebrity to see his or her details. Note that this time the ID
of the celebrity is present in the URL as displayed in the browser's address bar,
like this:
http://localhost:8084/celebrities/details/7
Create a bookmark and close the browser window. Open another one and
navigate to your bookmark. You should successfully see the details for the recently
bookmarked celebrity now.
As you can see, in a typical master-detail scenario, the PageLink component can do
a better job than ActionLink. This is not to say however that PageLink is always
superior. There definitely will be situations where ActionLink will be the only
reasonable candidate for example, when you want some complex logic to run as a
result of a click on a link, and not just pass a piece of information to another page.
Pages:
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146