Java Reference
In-Depth Information
Joe Asks. . .
What If I Don't Like How Messages Are Displayed?
By default, information messages are displayed in a plain
unordered list (<ul> and <li> tags). We'll see how to cus-
the contact list. Let's see about creating new contacts and updating
existing contacts with the Contact Form page.
3.6
Creating Forms
Forms are a breeze to create in Stripes. There is a Stripes tag for every
type of input field (text field, radio button, and so on) and for submit
buttons. Using these tags instead of plain HTML gives you extra fea-
tures such as repopulating the inputs, highlighting them when they
are in error, and supporting localization.
When the user submits a form, Stripes binds the values in the form
fields to the corresponding properties in the action bean and triggers
the event handler associated with the submit button. You can have
multiple submit buttons without having to do anything special to figure
out which button the user clicked: each button triggers its own event
handler on the action bean.
Input fields have to be associated to properties of an action bean, but
you don't have to copy the properties of a model object to the action
bean. Instead, you put the model object directly in the action bean and
use nested properties.
For example, you can add a
Contact
property in
ContactListActionBean
and create a text field associated with the contact's first name with
<s:text name="contact.firstName"/>
. To set the value, Stripes calls
getCon-
tact
( ).
setFirstName
( ) on the action bean. You don't even have to worry
about a
NullPointerException
. If
getContact
( ) returns
null
, Stripes creates a
new
Contact
object for you. This saves you a great deal of code because
you don't have to copy each model property in the action bean and
transfer information back and forth. If your model objects use other
Search WWH ::
Custom Search