Java Reference
In-Depth Information
Joe Asks. . .
Why Isn't BeanFirstPopulationStrategy Used by Default?
Why indeed? After all, it combines the best of both worlds: it
uses values you've set on action bean properties, and it falls
back to request parameters. It's certainly a good choice for
new Stripes applications. However, because BeanFirstPopulation-
Strategy wasn't introduced until Stripes 1.4, making it the default
would risk breaking backward compatibility in ways that would
be very difficult to track down. Perhaps a future version of
Stripes will make BeanFirstPopulationStrategy the default—with a
big loud warning about backward incompatibility—but as of
Stripes 1.5, you have to tell Stripes to use it.
MyPopulationStrategy is just an empty class, but since it extends BeanFirst-
PopulationStrategy , the effect is indeed to load this population strategy. 2
Just like that, Stripes uses the value that we set in the action bean
property to populate the text field. Our code combines recipients from
the text field, and the select box now works.
9.3
Using Indexed Properties
The Message Compose page includes fields for uploading files as attach-
ments, as shown in Figure 9.2 , on the following page.
The user can upload up to four files at a time. After clicking the Upload
button, the files are attached, and the user can upload more files.
Before we get to uploading files, we need to discuss how Stripes makes
it easy to manage a series of fields like we have for the attachments.
Notice that we're (arbitrarily) using four fields at a time—but we cer-
tainly don't need four properties in the action bean.
Whenever we're dealing with a series of rows of input fields that we
want to bind to the same property of an action bean, we'll want to use
what Stripes calls indexed properties.
2. You can also use a configuration parameter instead of an empty class; see the sidebar
on the following page.
 
 
 
Search WWH ::




Custom Search