Maybe a better solution is to provide default values as empty/null strings in
the action bean's property.
So if your property look like
private List<String> messages;
Try adding an initialisation method like
@Before(stages=LifecycleStage.BindingAndValidation)
public void populateDefaultMessages() {
messages = new ArrayList<String>();
for (int i = 0; i < 7; i++) {
messages.add("");
}
}
In your JSP, use indexed input fields like <stripes:textarea
name="messages[1]"/>
Remember that empty textarea will be replaced by null (default behaviour). But
I think you will still have an array of 7 elements.
Christian
-----Message d'origine-----
De : Iwao AVE! [mailto:[email protected]]
Envoyé : March-15-11 3:09 AM
À : Stripes Users List
Objet : Re: [Stripes-users] Index Properties + Null Values
Hi,
TypeConverter is for converting each value.
You need to write a custom ActionBeanPropertyBinder.
I wouldn't call it an easy way, but take a look at the default
implementation (DefaultActionBeanPropertyBinder) and see if you could
extend/override the default behavior.
Regards,
Iwao
2011/3/15 samuel baudouin <[email protected]>:
> Hi Adam!
>
> I would try converters : simply implement TypeConverter<String> and
> bind it to the entities you are trying to retrieve.
>
> I'd be interested to know how it worked!
>
> Cheers,
>
> Sam
>
> On Tue, Mar 15, 2011 at 2:29 PM, Adam Stokar <[email protected]> wrote:
>> Thanks for the quick response Iwao. Seems like the binding is what I am
>> talking about then. Is there an easy way to override the default behavior?
>>
>> On Tue, Mar 15, 2011 at 1:59 AM, Iwao AVE! <[email protected]> wrote:
>>>
>>> Hi Adam,
>>>
>>> Try specifying the index of each textarea explicitly.
>>>
>>> Mon: <stripes:textarea name="messages[0]" />
>>> Tue: <stripes:textarea name="messages[1]" />
>>> Wed: <stripes:textarea name="messages[2]" />
>>> ...
>>>
>>> FYI, all 7 values are submitted by the browser unless the form element
>>> is disabled.
>>> The difference is how these values are bound by Stripes.
>>>
>>> Hope this helps,
>>> Iwao
>>>
>>> 2011/3/15 Adam Stokar <[email protected]>:
>>> > Hi All,
>>> >
>>> > I am trying to submit a form with for a user's weekly hours.
>>> >
>>> > At the top of the form, there is a textarea for each day of the week to
>>> > type
>>> > a message. The message is optional.
>>> >
>>> > My intention is to submit the form and get 7 values, 1 for each
>>> > textarea,
>>> > regardless of whether the textarea is blank or not. Currently, if i
>>> > have a
>>> > message on Mon, Tues, and Thurs, I am only seeing 3 Strings in my
>>> > ActionBean
>>> > since Wed, Fri, Sat and Sun are all null when submitted. Is there a way
>>> > to
>>> > guarantee I submit 7 String values regardless of if the textarea have a
>>> > message or not?
>>> >
>>> > Thanks in advance,
>>> >
>>> > Adam
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users