Re: HashMap with String as key

2019-03-18 Thread Lukasz Lenart
czw., 14 mar 2019 o 21:38 Prasanth  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:
>  cssClass="inline-input"/>
>
> Resulting HTML:
>  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: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: HashMap with String as key

2019-03-14 Thread Prasanth
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:


Resulting HTML:


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



Re: HashMap with String as key

2019-03-14 Thread Lukasz Lenart
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
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: HashMap with String as key

2019-03-14 Thread Prasanth
The text field is also correctly populated based on the values in the hashmap 
(populated from database before showing the form). So the filed is correctly 
linked to the hashmap.

I have even tried using an alphabet as a separator but that doesn't work 
either. But if I remove the hyphen (2241923545 as key) then the hashmap is 
populated, but I wouldn't be able to get the two
values separated out if there is no separated. I could multiply one number with 
million and add another number to come up with a single number, but it will 
eventually create a problem as these keys grow.

If there a setting for struts that need to be changed to allow non numeric keys?

Thanks,
Prasanth

On 3/13/19 5:13 PM, Prasanth wrote:
> The html form generated is correctly showing the key but the hashmap doesn't 
> have a value for 22419-23545 when the form is submitted.
>
>  id="AccountAllocations_accountAllocation_22419-23545_" class="inline-input" 
> type="text"> Thanks, Prasanth
>
> On 3/12/19 9:26 AM, Prasanth Pasala wrote:
>> Lukasz,
>>
>> There is no new keys in the hash map. The hash map is not updated at all. 
>> Before the form is displayed to the user, the hash map is populated based on 
>> the data in the database. These values are
>> correctly displayed to the user in the text fields. But when the form is 
>> submitted by the user the data doesn't get populated in the hash map. Only 
>> the data I have populated in the hash map is present
>> (as the model class is stored in session using scope interceptor) doesn't 
>> matter what values I type in the text fields.
>>
>> Yasser,  That is right the key is a string, not long.
>>
>> Also as I was testing this (having keys with and with out hyphen) I realized 
>> that any values that I have added to hash map before showing the form are 
>> still in the map. The new values from the form
>> (keys without hyphen) got added to the hash map. I was under the impression 
>> that struts would set a new hash map with just the keys present in the form.
>>
>> Thanks,
>> Prasanth
>>
>> On 3/12/19 4:12 AM, Yasser Zamani wrote:
>>> (regarding your previous emails background) Please also consider that the 
>>> key 2432-123 is not further Long. It's String.
>>>
>>> Regards.
>>>
>>>> -Original Message-
>>>> From: Lukasz Lenart 
>>>> Sent: Tuesday, March 12, 2019 10:52 AM
>>>> To: Struts Users Mailing List 
>>>> Subject: Re: HashMap with String as key
>>>>
>>>> pon., 11 mar 2019 o 18:41 Prasanth  napisał(a):
>>>>> When you have a HashMap backed form and String as key, are there any
>>>> restrictions on the characters allowed?
>>>>> I have keys like "2432-123" as I have to incorporate two ids in the
>>>>> key. When I have these keys the HashMap is not getting populated. If I 
>>>>> change
>>>> it, so that there is only one id (no hyphen) then the data is getting 
>>>> posted as
>>>> expected.
>>>>
>>>> I assume it's because of the "-" (minus) sign, and OGNL performs an 
>>>> evaluation or
>>>> something. Could you check if you have key 2309 in your map as a result of
>>>> distraction operation (2432-123 = 2309)?
>>>>
>>>>
>>>> Regards
>>>> --
>>>> Łukasz
>>>> + 48 606 323 122 http://www.lenart.org.pl/
>>>>
>>>> -
>>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>>>> For additional commands, e-mail: user-h...@struts.apache.org
>>> -
>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>>> For additional commands, e-mail: user-h...@struts.apache.org
>>>
>



Re: HashMap with String as key

2019-03-13 Thread Prasanth
The html form generated is correctly showing the key but the hashmap doesn't 
have a value for 22419-23545 when the form is submitted.

 Thanks, Prasanth

On 3/12/19 9:26 AM, Prasanth Pasala wrote:
> Lukasz,
>
> There is no new keys in the hash map. The hash map is not updated at all. 
> Before the form is displayed to the user, the hash map is populated based on 
> the data in the database. These values are
> correctly displayed to the user in the text fields. But when the form is 
> submitted by the user the data doesn't get populated in the hash map. Only 
> the data I have populated in the hash map is present
> (as the model class is stored in session using scope interceptor) doesn't 
> matter what values I type in the text fields.
>
> Yasser,  That is right the key is a string, not long.
>
> Also as I was testing this (having keys with and with out hyphen) I realized 
> that any values that I have added to hash map before showing the form are 
> still in the map. The new values from the form
> (keys without hyphen) got added to the hash map. I was under the impression 
> that struts would set a new hash map with just the keys present in the form.
>
> Thanks,
> Prasanth
>
> On 3/12/19 4:12 AM, Yasser Zamani wrote:
>> (regarding your previous emails background) Please also consider that the 
>> key 2432-123 is not further Long. It's String.
>>
>> Regards.
>>
>>> -Original Message-
>>> From: Lukasz Lenart 
>>> Sent: Tuesday, March 12, 2019 10:52 AM
>>> To: Struts Users Mailing List 
>>> Subject: Re: HashMap with String as key
>>>
>>> pon., 11 mar 2019 o 18:41 Prasanth  napisał(a):
>>>> When you have a HashMap backed form and String as key, are there any
>>> restrictions on the characters allowed?
>>>> I have keys like "2432-123" as I have to incorporate two ids in the
>>>> key. When I have these keys the HashMap is not getting populated. If I 
>>>> change
>>> it, so that there is only one id (no hyphen) then the data is getting 
>>> posted as
>>> expected.
>>>
>>> I assume it's because of the "-" (minus) sign, and OGNL performs an 
>>> evaluation or
>>> something. Could you check if you have key 2309 in your map as a result of
>>> distraction operation (2432-123 = 2309)?
>>>
>>>
>>> Regards
>>> --
>>> Łukasz
>>> + 48 606 323 122 http://www.lenart.org.pl/
>>>
>>> -
>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>>> For additional commands, e-mail: user-h...@struts.apache.org
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>



Re: HashMap with String as key

2019-03-12 Thread Prasanth Pasala
Lukasz,

There is no new keys in the hash map. The hash map is not updated at all. 
Before the form is displayed to the user, the hash map is populated based on 
the data in the database. These values are
correctly displayed to the user in the text fields. But when the form is 
submitted by the user the data doesn't get populated in the hash map. Only the 
data I have populated in the hash map is present
(as the model class is stored in session using scope interceptor) doesn't 
matter what values I type in the text fields.

Yasser,  That is right the key is a string, not long.

Also as I was testing this (having keys with and with out hyphen) I realized 
that any values that I have added to hash map before showing the form are still 
in the map. The new values from the form
(keys without hyphen) got added to the hash map. I was under the impression 
that struts would set a new hash map with just the keys present in the form.

Thanks,
Prasanth

On 3/12/19 4:12 AM, Yasser Zamani wrote:
> (regarding your previous emails background) Please also consider that the key 
> 2432-123 is not further Long. It's String.
>
> Regards.
>
>> -Original Message-
>> From: Lukasz Lenart 
>> Sent: Tuesday, March 12, 2019 10:52 AM
>> To: Struts Users Mailing List 
>> Subject: Re: HashMap with String as key
>>
>> pon., 11 mar 2019 o 18:41 Prasanth  napisał(a):
>>> When you have a HashMap backed form and String as key, are there any
>> restrictions on the characters allowed?
>>> I have keys like "2432-123" as I have to incorporate two ids in the
>>> key. When I have these keys the HashMap is not getting populated. If I 
>>> change
>> it, so that there is only one id (no hyphen) then the data is getting posted 
>> as
>> expected.
>>
>> I assume it's because of the "-" (minus) sign, and OGNL performs an 
>> evaluation or
>> something. Could you check if you have key 2309 in your map as a result of
>> distraction operation (2432-123 = 2309)?
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>



RE: HashMap with String as key

2019-03-12 Thread Yasser Zamani
(regarding your previous emails background) Please also consider that the key 
2432-123 is not further Long. It's String.

Regards.

>-Original Message-
>From: Lukasz Lenart 
>Sent: Tuesday, March 12, 2019 10:52 AM
>To: Struts Users Mailing List 
>Subject: Re: HashMap with String as key
>
>pon., 11 mar 2019 o 18:41 Prasanth  napisał(a):
>> When you have a HashMap backed form and String as key, are there any
>restrictions on the characters allowed?
>>
>> I have keys like "2432-123" as I have to incorporate two ids in the
>> key. When I have these keys the HashMap is not getting populated. If I change
>it, so that there is only one id (no hyphen) then the data is getting posted as
>expected.
>
>I assume it's because of the "-" (minus) sign, and OGNL performs an evaluation 
>or
>something. Could you check if you have key 2309 in your map as a result of
>distraction operation (2432-123 = 2309)?
>
>
>Regards
>--
>Łukasz
>+ 48 606 323 122 http://www.lenart.org.pl/
>
>-
>To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>For additional commands, e-mail: user-h...@struts.apache.org



Re: HashMap with String as key

2019-03-12 Thread Lukasz Lenart
pon., 11 mar 2019 o 18:41 Prasanth  napisał(a):
> When you have a HashMap backed form and String as key, are there any 
> restrictions on the characters allowed?
>
> I have keys like "2432-123" as I have to incorporate two ids in the key. When 
> I have these keys the HashMap is not getting populated. If I change it, so 
> that there is only one id (no hyphen) then the
> data is getting posted as expected.

I assume it's because of the "-" (minus) sign, and OGNL performs an
evaluation or something. Could you check if you have key 2309 in your
map as a result of distraction operation (2432-123 = 2309)?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org