Java Reference
In-Depth Information
Since we added the gender property to the Contact class, the name= of
each radio button will be contact.gender . We just need ContactFormAc-
tionBean to supply the possible values for the gender:
Download email_19/src/stripesbook/action/ContactFormActionBean.java
public Gender[] getGenders() {
return Gender.values();
}
This makes it easy to create the radio buttons for the gender in con-
tact_form.jsp :
Download email_19/web/WEB-INF/jsp/contact_form.jsp
<c:forEach var="gender" items="${actionBean.genders}">
<s:radio name="contact.gender" value="${gender}"/> ${gender}
</c:forEach>
In the value= attribute is the actual value to submit as input to the
action bean property if the radio button is selected. This is the same
as if the user had typed that value in a text field. The value can be
different from the label that is shown next to the radio button; in fact,
notice that the label is not part of the
<s:radio>
tag at all. You can
display the label wherever you want.
The radio buttons for the gender now appear in the contact form, as
shown here:
What's Next?
We learned about the different types of form input controls and how
they work with Stripes tags and action bean properties. Along the way,
we got quite a lot done in the webmail application. In the next chap-
ter, we'll finish implementing the features of the Message List, Message
Details, and Message Compose pages.
 
 
Search WWH ::




Custom Search