out.println("The form was submitted!");
}
This handler does nothing except for giving an output message. Run the application,
submit some values at the Registration page, click on the Submit button, and you
should see that the message from the form submission handler appears after the
messages from the setter methods??”exactly as we expected.
Using Enumerations for Radio
Component Values
Right now, when the Registration page is rendered, none of the radio buttons are
selected. If you want, you can provide a default option by giving the gender property
an initial value, like this:
private String gender = "F";
Simple Components
[ 110 ]
Now the radio button labeled "Female" will be pre-selected.
The page works properly, but having a gender specified as an arbitrary string isn't
a good design. For a set of mutually exclusive options like this, it would be better
to have an enumeration. So let's add the following simple enumeration to the com.
packtpub.celebrities.model package:
package com.packtpub.celebrities.model;
public enum Gender
{
MALE, FEMALE
}
We can now modify all the gender-related code to work with the new Gender type
instead of String:
private Gender gender;
.
Pages:
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150