struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prasanth <>
Subject Re: HashMap with String as key
Date Thu, 14 Mar 2019 20:31:43 GMT
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.

<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">

Appreciate the input from everyone.

Thanks, Prasanth

On 3/14/19 2:36 PM, Lukasz Lenart wrote:
> czw., 14 mar 2019 o 20:11 Prasanth <> napisał(a):
>> If there a setting for struts that need to be changed to allow non numeric keys?
> Nothing like that, but I suggest to start over because you first
> reported that you want to have a numeric key and now you say you
> don't. So maybe start a new topic with an example code.
> I assume you have defined a numeric key in your Map and Struts tries
> to convert "2432-123" into a number and trims after the non-numeric
> character, that's why you see only "2432".
> Regards

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message