password2 = password2;
}
public String getGender()
{
return gender;
}
Chapter 4
[ 109 ]
public void setGender(String gender)
{
System.out.println("Setting gender: " + gender);
this.gender = gender;
}
}
The page class is very simple, but note that there are a few basic output statements
inserted into the setter methods??”they will help us to see what happens when the
form is submitted. If you run the application, go to the Registration page and submit
some information, you will see an output similar to this:
Setting user name: john
Setting password: abc123
Setting gender: M
We didn't provide any event handler for the form submission yet, and still
something is happening in the page class. When we click on the Submit button, the
values we have entered into the components surrounded by the form are sent to the
server. Tapestry extracts these values from the submitted information and assigns
them to the appropriate properties of the page class. After all the values are in place,
Tapestry checks if there is an event handler for the whole form, and if there is,
Tapestry executes it.
Let's provide such an event handler and see if everything works as we expect. Add
the following method to the Registration page class:
void onSubmitFromRegistrationForm()
{
System.
Pages:
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149