Re: Map backed form

2019-02-15 Thread Prasanth
Does struts follow a specific logic as to what the data type of the object 
would be based on user input? Meaning when is it converted to a Double vs 
Integer vs String?

Thanks,
Prasanth

On 2/15/19 7:45 AM, Lukasz Lenart wrote:
> pt., 15 lut 2019 o 00:17 Prasanth  napisał(a):
>> I have a map (Map) but based on the data entered by the user 
>> the value in the Map is Double or String. Example if the user enters a value 
>> of 10 then it is coming in as double but if the
>> user enters 10.5 then a string is present in the value. Does Struts2 look at 
>> the data types of the key and value of the map and set the key and values in 
>> the map accordingly?
> Struts is not a problem here, generic types are erased at runtime, so
> basically this a Map at the end
> https://docs.oracle.com/javase/tutorial/java/generics/erasure.html
>
>> If not, what is the best practice for the declaration of Map, is there a way 
>> to force Struts2 to only have Double objects as values?
> I would probably use a custom type instead of Double and implement
> converter for it, or even replace the Map with a List of custom
> objects.
>
>
> Regards



Re: Map backed form

2019-02-15 Thread Lukasz Lenart
pt., 15 lut 2019 o 00:17 Prasanth  napisał(a):
> I have a map (Map) but based on the data entered by the user 
> the value in the Map is Double or String. Example if the user enters a value 
> of 10 then it is coming in as double but if the
> user enters 10.5 then a string is present in the value. Does Struts2 look at 
> the data types of the key and value of the map and set the key and values in 
> the map accordingly?

Struts is not a problem here, generic types are erased at runtime, so
basically this a Map at the end
https://docs.oracle.com/javase/tutorial/java/generics/erasure.html

> If not, what is the best practice for the declaration of Map, is there a way 
> to force Struts2 to only have Double objects as values?

I would probably use a custom type instead of Double and implement
converter for it, or even replace the Map with a List of custom
objects.


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