czw., 14 mar 2019 o 21:38 Prasanth <[email protected]> napisał(a):
>
> Sorry if I caused any confusion. This thread was meant to discuss String
> keys. I do have forms where I am using numeric keys and they work fine.
>
> I think I found a solution to my problem. Struts seems to expect single
> quotes for the keys when the key is string. Updated code is shown below. Also
> I changed my separator to "a" rather than "-". So
> the two changes I have made are i) change separator to "a" ii) use single
> quotes around the key when specifying the name for text field.
>
> JSP:
> <s:textfield name="accountAllocation[*'*%{#attr.mapKey}*'*]" size="3"
> cssClass="inline-input"/>
>
> Resulting HTML:
> <input name="accountAllocation['22419a23543']" size="3" value="50"
> id="AccountAllocations_accountAllocation_'22419a23543'_" class="inline-input"
> type="text">
Ok, now we have a clear situation. The "name" attribute is evaluated
as an OGNL expression so in this case everything enclosed will be
parsed and treated as expression, from inner to outer.
Using "%" forces an additional evaluation but enclosing it in a single
quote (') means you expect a String so this expression
'%{#attr.mapKey}' should only return '12345-123', then
"accountAllocation[]" is evaluated as a map with a key (in this case
with a String key).
So using single quotes should do the trick in your case.
Kind regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]