DoubleBox and Editor framework bug?

223 views
Skip to first unread message

Daniel Mauricio Patino León

unread,
Nov 11, 2012, 2:05:49 AM11/11/12
to google-we...@googlegroups.com
Its normal when i use a DoubleBox in a Editor to edit a double property (RequestFactoryEditorDriver)
if i clear the value of the box i get a null pointer exception?

If so how can i validate a DoubleBox with the JSR 303 Validation?

My code looks something like this:

@DecimalMin(value="0.0", message="decimalMin:0.0", groups = {ImpuestoGroup.class, ImpuestoIepsGroup.class})
public double getTasaImpuesto();

<g:DoubleBox ui:field="tasaImpuesto"></g:DoubleBox>
@UiField DoubleBox tasaImpuesto;

When i call the driver.flush() need to check the constraints i have this results:

if i put a value diferent than number i get the on the List<EditorError> the bad value
if i put a lower than 0.0 value i can set the constraints to the EditorDriver with driver.setConstraintViolations(constraints);

When i leave blank the field i expect a List<EditorError> with a bad value or the constraint but not a null pointer exception.

The line i get my atention is this one:

Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read property 'value_0' of null

Seems that DoubleBox cannot handle the null value.

Please help me. Thank you.

This the stack trace of Superdev Mode:

00:56:19 GMT-600 2012 com.google.gwt.logging.client.LogConfiguration
SEVERE: Exception caught: Exception caught: (TypeError) : Cannot read property 'value_0' of null
com.google.gwt.event.shared.UmbrellaException: Exception caught: Exception caught: (TypeError) : Cannot read property 'value_0' of null
Caused by: com.google.gwt.event.shared.UmbrellaException: Exception caught: (TypeError) : Cannot read property 'value_0' of null
Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read property 'value_0' of null


Daniel Mauricio Patino León

unread,
Nov 11, 2012, 1:46:12 PM11/11/12
to google-we...@googlegroups.com
Seems that edioto framework is trying to get the Double.doubleValue() without check if the object is null.

Any one ?

2012/11/11 Daniel Mauricio Patino León <ceo.li...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/iAU0wx_nWj8J.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
ISC. Daniel Mauricio Patiño León.
Director ejecutivo
Liondev S.A. de C.V.



Thomas Broyer

unread,
Nov 11, 2012, 5:04:51 PM11/11/12
to google-we...@googlegroups.com


On Sunday, November 11, 2012 7:47:11 PM UTC+1, Daniel Mauricio Patino León wrote:
Seems that edioto framework is trying to get the Double.doubleValue() without check if the object is null.

Any one ?

DoubleBox uses DoubleParser. DoubleParser returns 'null' if the value is the empty string, and otherwise uses a NumberFormat, and throws a ParserException if it cannot parse. Your edited object's property is of type 'double', not 'java.lang.Double', so when the field is empty, getValue() returns 'null', and the Editor framework tries to unbox the 'null' to put it into your 'double' property, hence the NullPointerException. With any illegal value, DoubleParser throws; in that case, the ValueBoxEditor returns the last known value, which explains why it doesn't throw in that case.
I think you can file an issue, but I wonder what the fix should be (if any): what value should be put into your property when the field is empty (i.e. the value is 'null')? or should the Editor framework generate specific code for primitive values to handle nulls and report errors without trying to change the value (to avoid NPEs)?

Daniel Mauricio Patino León

unread,
Nov 11, 2012, 11:10:50 PM11/11/12
to google-we...@googlegroups.com
Hello Thomas, thank you for your answer.

I understand how the ValueBox with their Render and Parser works.

And i understand the difference using Double and double, so a work arround would be use Double wrapper instead primitive types?

I think would be nice if the editor generate some code to handle this case and report like when the user use some bad input and then this can be reported in to the getErrors() so the NPE wont be raised.

Like when you use bad values
(1a) Bad value(1a)
(empty) bad value(null)

I will put a issue.


2012/11/11 Thomas Broyer <t.br...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Reply all
Reply to author
Forward
0 new messages