You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Milan Milanovic <mi...@yahoo.com> on 2008/08/21 19:00:20 UTC
[S2] Double conversion issue
Hi,
I have this code in my jsp:
<s:iterator value="someObject" status="rowstatus">
...
<s:url id="removeUrl" action="remove">
<s:param name="prop" value="prop" />
</s:url>
<s:a id="a_%{prop}" href="%{removeUrl}" theme="ajax" notifyTopics="/delete"
targets="fruits">Delete</s:a>
...
</s:iterator>
This "remove.action" is mapped into remove() method in my action class, and
"prop" is a double property with get/set methods in my action class.
What happens now, when user enter, e.g. 1234.0 for "prop", it is well
represented here, e.g. "prop" value is 1234.0 in jsp and my list in action
class, but when user click on the link above to delete it, in my action
class remove() method for "prop" I get: 12340.0 ! Zero is always added at
end of the number, does anyone know why this could happen ?
--
Regards, Milan
--
View this message in context: http://www.nabble.com/-S2--Double-conversion-issue-tp19092842p19092842.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Milan Milanovic <mi...@yahoo.com>.
Hi Jeromy,
well, if someone have this converter, please give it here.
I use BigDecimals for currency, this double is just for representing some
real values.
--
Milan
Jeromy Evans - Blue Sky Minds wrote:
>
> Milan Milanovic wrote:
>> Uf, bug again :-(((.
>>
>> Is there any custom type-converter for Double-s that doesn't have this
>> error
>> ?
>>
>> --
>> Milan
>>
>
> A custom type-converter means you can write one yourself for that
> specific property. It's very simple:
>
> http://struts.apache.org/2.0.11.2/docs/type-conversion.html
>
> Personally I never use Double in an action and instead opt for
> BigDecimal to maintain precision correctly.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/-S2--Double-conversion-issue-tp19092842p19122944.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Milan Milanovic <mi...@yahoo.com>.
One more this why is this wierd, because when number is entered through
textfield it is converted good with default Double convertor, but when it is
converted from jsp link (as I give above) it add 0 to the end..
--
Milan
Jeromy Evans - Blue Sky Minds wrote:
>
> Milan Milanovic wrote:
>> Uf, bug again :-(((.
>>
>> Is there any custom type-converter for Double-s that doesn't have this
>> error
>> ?
>>
>> --
>> Milan
>>
>
> A custom type-converter means you can write one yourself for that
> specific property. It's very simple:
>
> http://struts.apache.org/2.0.11.2/docs/type-conversion.html
>
> Personally I never use Double in an action and instead opt for
> BigDecimal to maintain precision correctly.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/-S2--Double-conversion-issue-tp19092842p19145493.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Milan Milanovic <mi...@yahoo.com>.
O.K. Solved. I added this property in wrong properties file. Sorry.
--
Milan
Milan Milanovic wrote:
>
> I put in my MyActionClass-conversion.properties file like this:
>
> prop = com.myProject.conversions.DoubleConverter
>
> But when user click on the "Delete" link, it is the same, 0 is added at
> the end of the Double, so I supose that this converter is not called, as
> prop is send through params ? It seems that these converters works only
> for form fields ?
>
> --
> Milan
>
>
>
> Milan Milanovic wrote:
>>
>> I have defined new DoubleConverter, but now I don't know how to define
>> conversion in MyActionClass-conversion.properties file. I know how to
>> define it for form fields, but how to define it for a link, like below:
>>
>> <s:url id="removeUrl" action="remove">
>> <s:param name="prop" value="prop" />
>> </s:url>
>> <s:a id="a_%{prop}" href="%{removeUrl}" theme="ajax"
>> notifyTopics="/delete" targets="fruits">Delete</s:a>
>>
>> ?
>>
>> "prop" is Double.
>>
>> --
>> Thx, Milan
>>
>>
>>
>> Jeromy Evans - Blue Sky Minds wrote:
>>>
>>> Milan Milanovic wrote:
>>>> Uf, bug again :-(((.
>>>>
>>>> Is there any custom type-converter for Double-s that doesn't have this
>>>> error
>>>> ?
>>>>
>>>> --
>>>> Milan
>>>>
>>>
>>> A custom type-converter means you can write one yourself for that
>>> specific property. It's very simple:
>>>
>>> http://struts.apache.org/2.0.11.2/docs/type-conversion.html
>>>
>>> Personally I never use Double in an action and instead opt for
>>> BigDecimal to maintain precision correctly.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/-S2--Double-conversion-issue-tp19092842p19163707.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Milan Milanovic <mi...@yahoo.com>.
I put in my MyActionClass-conversion.properties file like this:
prop = com.myProject.conversions.DoubleConverter
But when user click on the "Delete" link, it is the same, 0 is added at the
end of the Double, so I supose that this converter is not called, as prop is
send through params ? It seems that these converters works only for form
fields ?
--
Milan
Milan Milanovic wrote:
>
> I have defined new DoubleConverter, but now I don't know how to define
> conversion in MyActionClass-conversion.properties file. I know how to
> define it for form fields, but how to define it for a link, like below:
>
> <s:url id="removeUrl" action="remove">
> <s:param name="prop" value="prop" />
> </s:url>
> <s:a id="a_%{prop}" href="%{removeUrl}" theme="ajax"
> notifyTopics="/delete" targets="fruits">Delete</s:a>
>
> ?
>
> "prop" is Double.
>
> --
> Thx, Milan
>
>
>
> Jeromy Evans - Blue Sky Minds wrote:
>>
>> Milan Milanovic wrote:
>>> Uf, bug again :-(((.
>>>
>>> Is there any custom type-converter for Double-s that doesn't have this
>>> error
>>> ?
>>>
>>> --
>>> Milan
>>>
>>
>> A custom type-converter means you can write one yourself for that
>> specific property. It's very simple:
>>
>> http://struts.apache.org/2.0.11.2/docs/type-conversion.html
>>
>> Personally I never use Double in an action and instead opt for
>> BigDecimal to maintain precision correctly.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/-S2--Double-conversion-issue-tp19092842p19163084.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Milan Milanovic <mi...@yahoo.com>.
I have defined new DoubleConverter, but now I don't know how to define
conversion in MyActionClass-conversion.properties file. I know how to define
it for form fields, but how to define it for a link, like below:
<s:url id="removeUrl" action="remove">
<s:param name="prop" value="prop" />
</s:url>
<s:a id="a_%{prop}" href="%{removeUrl}" theme="ajax" notifyTopics="/delete"
targets="fruits">Delete</s:a>
?
"prop" is Double.
--
Thx, Milan
Jeromy Evans - Blue Sky Minds wrote:
>
> Milan Milanovic wrote:
>> Uf, bug again :-(((.
>>
>> Is there any custom type-converter for Double-s that doesn't have this
>> error
>> ?
>>
>> --
>> Milan
>>
>
> A custom type-converter means you can write one yourself for that
> specific property. It's very simple:
>
> http://struts.apache.org/2.0.11.2/docs/type-conversion.html
>
> Personally I never use Double in an action and instead opt for
> BigDecimal to maintain precision correctly.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/-S2--Double-conversion-issue-tp19092842p19144757.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Milan Milanovic wrote:
> Uf, bug again :-(((.
>
> Is there any custom type-converter for Double-s that doesn't have this error
> ?
>
> --
> Milan
>
A custom type-converter means you can write one yourself for that
specific property. It's very simple:
http://struts.apache.org/2.0.11.2/docs/type-conversion.html
Personally I never use Double in an action and instead opt for
BigDecimal to maintain precision correctly.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Milan Milanovic <mi...@yahoo.com>.
Uf, bug again :-(((.
Is there any custom type-converter for Double-s that doesn't have this error
?
--
Milan
Jeromy Evans - Blue Sky Minds wrote:
>
> I've seen this reported previous as a bug in S2/Xwork (appending an
> extra 0 character). I can't recall where I saw that.
>
> Write a custom type-converter for that field to work-around it.
>
> Milan Milanovic wrote:
>> This is some wierd Struts behaviour for Double conversion, e.g., if my
>> prop
>> attribute in JSP was 2232.435, when user click on this "Delete" link, in
>> my
>> action class for prop attribute I get: 2232435.0 ?!
>>
>> --
>> Milan
>>
>>
>>
>> Milan Milanovic wrote:
>>
>>> Hi,
>>>
>>> I have this code in my jsp:
>>>
>>> <s:iterator value="someObject" status="rowstatus">
>>> ...
>>> <s:url id="removeUrl" action="remove">
>>> <s:param name="prop" value="prop" />
>>> </s:url>
>>> <s:a id="a_%{prop}" href="%{removeUrl}" theme="ajax"
>>> notifyTopics="/delete" targets="fruits">Delete</s:a>
>>> ...
>>> </s:iterator>
>>>
>>> This "remove.action" is mapped into remove() method in my action class,
>>> and "prop" is a double property with get/set methods in my action class.
>>>
>>> What happens now, when user enter, e.g. 1234.0 for "prop", it is well
>>> represented here, e.g. "prop" value is 1234.0 in jsp and my list in
>>> action
>>> class, but when user click on the link above to delete it, in my action
>>> class remove() method for "prop" I get: 12340.0 ! Zero is always added
>>> at
>>> end of the number, does anyone know why this could happen ?
>>>
>>> --
>>> Regards, Milan
>>>
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/-S2--Double-conversion-issue-tp19092842p19120558.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
I've seen this reported previous as a bug in S2/Xwork (appending an
extra 0 character). I can't recall where I saw that.
Write a custom type-converter for that field to work-around it.
Milan Milanovic wrote:
> This is some wierd Struts behaviour for Double conversion, e.g., if my prop
> attribute in JSP was 2232.435, when user click on this "Delete" link, in my
> action class for prop attribute I get: 2232435.0 ?!
>
> --
> Milan
>
>
>
> Milan Milanovic wrote:
>
>> Hi,
>>
>> I have this code in my jsp:
>>
>> <s:iterator value="someObject" status="rowstatus">
>> ...
>> <s:url id="removeUrl" action="remove">
>> <s:param name="prop" value="prop" />
>> </s:url>
>> <s:a id="a_%{prop}" href="%{removeUrl}" theme="ajax"
>> notifyTopics="/delete" targets="fruits">Delete</s:a>
>> ...
>> </s:iterator>
>>
>> This "remove.action" is mapped into remove() method in my action class,
>> and "prop" is a double property with get/set methods in my action class.
>>
>> What happens now, when user enter, e.g. 1234.0 for "prop", it is well
>> represented here, e.g. "prop" value is 1234.0 in jsp and my list in action
>> class, but when user click on the link above to delete it, in my action
>> class remove() method for "prop" I get: 12340.0 ! Zero is always added at
>> end of the number, does anyone know why this could happen ?
>>
>> --
>> Regards, Milan
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Milan Milanovic <mi...@yahoo.com>.
This is some wierd Struts behaviour for Double conversion, e.g., if my prop
attribute in JSP was 2232.435, when user click on this "Delete" link, in my
action class for prop attribute I get: 2232435.0 ?!
--
Milan
Milan Milanovic wrote:
>
> Hi,
>
> I have this code in my jsp:
>
> <s:iterator value="someObject" status="rowstatus">
> ...
> <s:url id="removeUrl" action="remove">
> <s:param name="prop" value="prop" />
> </s:url>
> <s:a id="a_%{prop}" href="%{removeUrl}" theme="ajax"
> notifyTopics="/delete" targets="fruits">Delete</s:a>
> ...
> </s:iterator>
>
> This "remove.action" is mapped into remove() method in my action class,
> and "prop" is a double property with get/set methods in my action class.
>
> What happens now, when user enter, e.g. 1234.0 for "prop", it is well
> represented here, e.g. "prop" value is 1234.0 in jsp and my list in action
> class, but when user click on the link above to delete it, in my action
> class remove() method for "prop" I get: 12340.0 ! Zero is always added at
> end of the number, does anyone know why this could happen ?
>
> --
> Regards, Milan
>
--
View this message in context: http://www.nabble.com/-S2--Double-conversion-issue-tp19092842p19116746.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Double conversion issue
Posted by Milan Milanovic <mi...@yahoo.com>.
I checked this with Firebug and in jsp, "prop" is O.K.:
...
# Delete
...
But, when user click on the link, in action class I get 12340.0 !!
--
Regards, Milan
Milan Milanovic wrote:
>
> Hi,
>
> I have this code in my jsp:
>
> <s:iterator value="someObject" status="rowstatus">
> ...
> <s:url id="removeUrl" action="remove">
> <s:param name="prop" value="prop" />
> </s:url>
> <s:a id="a_%{prop}" href="%{removeUrl}" theme="ajax"
> notifyTopics="/delete" targets="fruits">Delete</s:a>
> ...
> </s:iterator>
>
> This "remove.action" is mapped into remove() method in my action class,
> and "prop" is a double property with get/set methods in my action class.
>
> What happens now, when user enter, e.g. 1234.0 for "prop", it is well
> represented here, e.g. "prop" value is 1234.0 in jsp and my list in action
> class, but when user click on the link above to delete it, in my action
> class remove() method for "prop" I get: 12340.0 ! Zero is always added at
> end of the number, does anyone know why this could happen ?
>
> --
> Regards, Milan
>
--
View this message in context: http://www.nabble.com/-S2--Double-conversion-issue-tp19092842p19093011.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org