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 150 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

How do we
write it? Based on our previous experience with event handlers, we might write
something like this:
@OnEvent(component="submitButton")
Object onSubmitButton()
{
System.out.println("Submit button was pressed!");
User newUser = new User("John", "Johnson");
this.user = newUser;
return ShowAll.class;
}
This should be all right, shouldn't it? We are doing what we want to do inside the
method, and then returning a class to tell Tapestry which page to display next. This
will not work however, at least in the current version of Tapestry. For now, the rule
is that the event handler for Submit must not return anything. Then how can we
navigate to another page?
If you remember, in the output that we received when running the application
recently, we could see that a form submission handler was invoked straight after the
Submit button event handler. It always happens like this, as the Submit component
is always surrounded by a Form component, which gives us an opportunity to solve
our problem in the following way:
Chapter 4
[ 119 ]
private Class nextPage;
Object onSubmitFromRegistrationForm()
{
System.out.println("The form was submitted!");
if (unsubscribe) subscribe = false;
return nextPage;
}
@OnEvent(component="submitButton")
void onSubmitButton()
{
System.


Pages:
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6