newton.dave wrote:
>
> Timmos wrote:
>> Hi,
>>
>> I figured out how to generate a form with dynamic length. The submitting
>> part remains a bit tricky, but before you redirect me to OGNL / Type
>> Conversion pages, I have to say I already read those articles.
>>
>> This is a part of my generated .jsp (the generate part - I won't include
>> the
>> Action code for this):
>>
>> <s:iterator value="properties" status="stat">
>> <s:textfield name="lijst[2]" label="%{name}" />
>> </s:iterator>
>>
>> As you can see, for testing purposes I hard-coded the index "2", but I
>> don't
>> know if this syntax is correct.
>>
>> This form is to be submitted to DoSearchAction:
>>
>> public void setLijst(int index, String s) {
>> lijst[index] = s;
>> System.out.println(">>>> LIJST!!! >> " + index + ":::" + s);
>> }
>>
>> When I run this piece of junk, I get: ognl.OgnlException: target is null
>> for
>> setProperty(null, "2", [Ljava.lang.String;@13dd8).
>>
>> I would like to know what is wrong with the setter / s:textfield name
>> parameter. What do I have to do to get it working?
>
> (1) If there are multiple parameters w/ the same name the framework
> appears to put them into a collection: it may not be necessary to do
> *anything*.
>
> (2) IIRC using indexed setters would use the (n) syntax (not [n]), but I
> could be remembering wrong. In any case, you don't need to use an
> indexed setter, just have an appropriate collection property with a
> setter, say:
>
> private List<String> lijst;
> public void setLijst(List l) { lijst = l; }
>
> (Or whatever.)
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
Thx. What should the name attributes of my textfield be then, knowing that
"lijst" is my List to set?
<s:textfield value="" name"lijst" /> ? And it should work?
--
View this message in context:
http://www.nabble.com/Struts-2---Dynamic-form%3A-submitting-issues-tp22755036p22779033.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]