As you
will see soon, this ID will allow us to define exactly which celebrity we want to be
displayed by the Details page.
We already know quite a number of features that have to be present in the ShowAll
page class, so here is the complete code for this class:
package com.packtpub.celebrities.pages;
import com.packtpub.celebrities.data.MockDataSource;
import com.packtpub.celebrities.model.Celebrity;
import com.packtpub.celebrities.util.Formats;
import com.packtpub.celebrities.model.User;
import java.text.Format;
import java.util.List;
import org.apache.tapestry.annotations.ApplicationState;
import org.apache.tapestry.annotations.InjectPage;
import org.apache.tapestry.annotations.OnEvent;
public class ShowAll
{
@ApplicationState
private User user;
private boolean userExists;
@ApplicationState
private MockDataSource dataSource;
@InjectPage
private Details detailsPage;
private Celebrity celebrity;
String onActivate()
{
if (!userExists) return "Start";
return null;
}
@OnEvent(component="detailsLink")
Object onShowDetails(long id)
Simple Components
[ 100 ]
{
Celebrity celebrity = dataSource.getCelebrityById(id);
detailsPage.setCelebrity(celebrity);
return detailsPage;
}
public List
getAllCelebrities()
{
return dataSource.
Pages:
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139