Re: BigInteger and BigDecimal Properties Issue

2007-06-26 Thread Mark Menard
On 6/25/07 7:19 PM, Mark Menard [EMAIL PROTECTED] wrote:

 I have an action with a property of type BigDecimal, that is initialized, so
 it has a value:
 
 Public class myAction {
  BigDecimal myBigDecimal = new BigDecimal (1.1);
 
  ...
 }
 
 I have a form with the following:
 
 s:textfield name=myBigDecimal /
 
 The issue is if I blank out the value, myBigDecimal still retains the 1.1
 value in the action.

I overcame this behavior by writing my own type converter.
 
 Questions:
 
 When a field is a java.lang.Number, and the input is blank, should null be
 set on the property?
 
 Looking at ognl.OgnlOps.doubleValue() for a 0 length string it should be
 returning 0.0, why is it null?

This still leaves the question on what the default behavior ought to be. My
thought is the properties should be set to null.

Mark

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



BigInteger and BigDecimal Properties Issue

2007-06-25 Thread Mark Menard
I have an action with a property of type BigDecimal, that is initialized, so
it has a value:

Public class myAction {
   BigDecimal myBigDecimal = new BigDecimal (1.1);

   ...
}

I have a form with the following:

s:textfield name=myBigDecimal /

The issue is if I blank out the value, myBigDecimal still retains the 1.1
value in the action.

I have dug into OGNL and it seems to me like it is not setting the value
null because when it tries to create a new BigDecimal with the  string it
throws a NumberFormatException. (cf: ognl.OgnlOps.bigDecValue() ) (Strangely
enough this does not propagate up to show as an error on the form.)

Now, if I change the type to Double, and leave the input on the form blank,
the value stays blank, and is null in my debug log. (Looking at
ognl.OglOps.doubleValue() it ought to be 0.0, but it's null.)

Questions:

When a field is a java.lang.Number, and the input is blank, should null be
set on the property?

Looking at ognl.OgnlOps.doubleValue() for a 0 length string it should be
returning 0.0, why is it null?

Opinion:

I think that if a field is submitted as the  String from the browser the
field should be set null if it is a java.lang.Number.

Thanks,

Mark

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]