You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by George Eapen <ge...@gmail.com> on 2012/05/06 15:53:03 UTC

Struts 2 -Big Decimal auto conversion issue

Dear All,

Big Decimal auto conversion fails when an empty string is received.Excerpt
of the stack given below.

/-- Encapsulated exception ------------\
java.lang.NoSuchMethodException:
com.path.ConvTest.setId([Ljava.lang.String;)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
 at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)

When an empty string is received from the client it searches for a method
with argument String instead of Big Decimal.But works perfectly fine if the
value is not empty.If Big Decimal data type is changed to Integer then
there is no issue even if the value is empty string.Could you please let me
know why this happens or am i missing something.Thank you

-- 
Regards,
George Eapen

Re: Struts 2 -Big Decimal auto conversion issue

Posted by George Eapen <ge...@gmail.com>.
Thanx Dave

On Sun, May 6, 2012 at 4:56 PM, Dave Newton <da...@gmail.com> wrote:

> Because it uses the default BigDecimal parsing.
>
> Options include:
>
> * Using an interceptor to strip leading/trailing spaces from form elements
> before type conversion
> * Using a custom type converter that does basically the same thing
> * Etc.
>
> Dave
>
> On Sun, May 6, 2012 at 9:53 AM, George Eapen <georgeeapen07@gmail.com
> >wrote:
>
> > Dear All,
> >
> > Big Decimal auto conversion fails when an empty string is
> received.Excerpt
> > of the stack given below.
> >
> > /-- Encapsulated exception ------------\
> > java.lang.NoSuchMethodException:
> > com.path.ConvTest.setId([Ljava.lang.String;)
> > at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
> >  at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)
> >
> > When an empty string is received from the client it searches for a method
> > with argument String instead of Big Decimal.But works perfectly fine if
> the
> > value is not empty.If Big Decimal data type is changed to Integer then
> > there is no issue even if the value is empty string.Could you please let
> me
> > know why this happens or am i missing something.Thank you
> >
> > --
> > Regards,
> > George Eapen
> >
>



-- 
Regards,
George Eapen

The biggest risk is not taking any riskā€¦In a world that is changing really
quickly, the only strategy that is guaranteed to fail is not taking risks

Re: Struts 2 -Big Decimal auto conversion issue

Posted by Dave Newton <da...@gmail.com>.
Because it uses the default BigDecimal parsing.

Options include:

* Using an interceptor to strip leading/trailing spaces from form elements
before type conversion
* Using a custom type converter that does basically the same thing
* Etc.

Dave

On Sun, May 6, 2012 at 9:53 AM, George Eapen <ge...@gmail.com>wrote:

> Dear All,
>
> Big Decimal auto conversion fails when an empty string is received.Excerpt
> of the stack given below.
>
> /-- Encapsulated exception ------------\
> java.lang.NoSuchMethodException:
> com.path.ConvTest.setId([Ljava.lang.String;)
> at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
>  at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)
>
> When an empty string is received from the client it searches for a method
> with argument String instead of Big Decimal.But works perfectly fine if the
> value is not empty.If Big Decimal data type is changed to Integer then
> there is no issue even if the value is empty string.Could you please let me
> know why this happens or am i missing something.Thank you
>
> --
> Regards,
> George Eapen
>