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

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"


That code should be executed as a result of form submission??”in other words, we
need to create an event handler for the submit event of the Form component that we
have placed on the page. A Form component can generate a few other events too, but
this will be explained in a later chapter.
The Foundations of Tapestry
[ 60 ]
In Tapestry 5 any method can be an event handler, no matter what we name it. To
tell Tapestry when to invoke this method, we use the @OnEvent annotation, and also
provide it with the ID of the component that the event handler should be associated
with. For some components like Form, we also need to specify which event this
method should handle, as the component can produce more than just one event.
Add the following method to the Start page class:
@OnEvent(value="submit", component="userInputForm")
void onFormSubmit()
{
System.out.println("Handling form submission!");
}
Please note the default (or package) access level used for this method??”the method
wasn't declared as either private or public. This is a preferred approach for an event
handler in Tapestry 5, and it makes a lot of sense. On one hand, this method serves a
specific purpose and we do not want to leave it accessible to just everyone by making
it public.


Pages:
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6