Java Reference
In-Depth Information
Stripes Form Input Tags
All Stripes form input tags use the name= attribute to bind the
value of the input to an action bean property. Also note that
these tags must always be nested within an <s:form> tag.
Using Stripes form input tags gives Stripes a chance to do sev-
eral things for you, such as automatically populating the fields
with existing data. This works both for updating the properties
of an existing object and for redisplaying a form when valida-
tion errors have occurred. Other goodies include adding the
maxlength= attribute to a text field when the corresponding
property has a maxlength= validation, using model objects to
generate options in a select box (as we'll see in this chapter),
and looking up labels in resource bundles (explored in Chap-
ter 11 , Parlez-Vous Français? Making It Multilingual.)
Finally, the Stripes input tags also support all HTML attributes.
The attributes for which Stripes has no use are passed through
without modification. Yes, this includes the class= attribute—you
don't have to use styleClass= , cssClass= , or any other renamed
attribute like some other frameworks require you to do.
We can use a List<Message> property in order to receive all the selected
messages: 1
Download email_19/src/stripesbook/action/MessageListActionBean.java
private List<Message> selectedMessages;
public List<Message> getSelectedMessages() {
return selectedMessages;
}
public void setSelectedMessages(List<Message> selectedMessages) {
this .selectedMessages = selectedMessages;
}
When the user submits the form, selectedMessages will contain the mes-
sages that the user checked. It's very simple, then, to do something with
these messages in an event handler.
1. This is one of several ways to use checkboxes. I explain the different ways in the
sidebar on page 171 .
 
Search WWH ::




Custom Search