Reghin
17 Aug 2009, 5:48 AM
Hello guys.
In my application I have a need for real big numbers for monetary calculations. There is a BigDecimal for GWT (http://code.google.com/p/gwt-math/) that is supposed to help out on this.
When I edit (change the value) a NumberField I get an exception saying:
[ERROR] Uncaught exception escaped
java.lang.ClassCastException: java.lang.Double cannot be cast to java.math.BigDecimal
at br.com.ierp.gxt.entity.BeanModel_br_com_ierp_gxt_entity_Carteira.set(transient source for br.com.ierp.gxt.entity.BeanModel_br_com_ierp_gxt_entity_Carteira:224)
at com.extjs.gxt.ui.client.store.Record.set(Record.java:287)
at com.extjs.gxt.ui.client.binding.FieldBinding.updateModel(FieldBinding.java:178)
at com.extjs.gxt.ui.client.binding.FieldBinding.onFieldChange(FieldBinding.java:201)
at com.extjs.gxt.ui.client.binding.FieldBinding$1.handleEvent(FieldBinding.java:53)
at com.extjs.gxt.ui.client.binding.FieldBinding$1.handleEvent(FieldBinding.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:176)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:96)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:444)
at com.extjs.gxt.ui.client.widget.form.Field.fireChangeEvent(Field.java:1005)
at com.extjs.gxt.ui.client.widget.form.Field.onBlur(Field.java:1046)
at com.extjs.gxt.ui.client.widget.form.TextField.onBlur(TextField.java:405)
at com.extjs.gxt.ui.client.widget.form.Field.onComponentEvent(Field.java:600)
at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:760)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1320)
at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1299)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1262)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
One thing to be noticed is that I do NOT get the error when I type any value for the first time (insert), and I also do NOT get any error when I display and populate the grid and fields in the form.
This is the code to set the NumberField to work with the BigDecimal class:
fieldValorPrevistoReal = new NumberField();
fieldValorPrevistoReal.setPropertyEditorType(BigDecimal.class);
Or this one:
fieldValorPrevistoReal = new NumberField();
fieldValorPrevistoReal.setPropertyEditor(new NumberPropertyEditor(BigDecimal.class));Neither of them seem to solve the problem.
How do I get GXT to support BigDecimal??
BTW: using GXT 2.0.1 and GWT 1.7.
In my application I have a need for real big numbers for monetary calculations. There is a BigDecimal for GWT (http://code.google.com/p/gwt-math/) that is supposed to help out on this.
When I edit (change the value) a NumberField I get an exception saying:
[ERROR] Uncaught exception escaped
java.lang.ClassCastException: java.lang.Double cannot be cast to java.math.BigDecimal
at br.com.ierp.gxt.entity.BeanModel_br_com_ierp_gxt_entity_Carteira.set(transient source for br.com.ierp.gxt.entity.BeanModel_br_com_ierp_gxt_entity_Carteira:224)
at com.extjs.gxt.ui.client.store.Record.set(Record.java:287)
at com.extjs.gxt.ui.client.binding.FieldBinding.updateModel(FieldBinding.java:178)
at com.extjs.gxt.ui.client.binding.FieldBinding.onFieldChange(FieldBinding.java:201)
at com.extjs.gxt.ui.client.binding.FieldBinding$1.handleEvent(FieldBinding.java:53)
at com.extjs.gxt.ui.client.binding.FieldBinding$1.handleEvent(FieldBinding.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:176)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:96)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:444)
at com.extjs.gxt.ui.client.widget.form.Field.fireChangeEvent(Field.java:1005)
at com.extjs.gxt.ui.client.widget.form.Field.onBlur(Field.java:1046)
at com.extjs.gxt.ui.client.widget.form.TextField.onBlur(TextField.java:405)
at com.extjs.gxt.ui.client.widget.form.Field.onComponentEvent(Field.java:600)
at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:760)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1320)
at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1299)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1262)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
One thing to be noticed is that I do NOT get the error when I type any value for the first time (insert), and I also do NOT get any error when I display and populate the grid and fields in the form.
This is the code to set the NumberField to work with the BigDecimal class:
fieldValorPrevistoReal = new NumberField();
fieldValorPrevistoReal.setPropertyEditorType(BigDecimal.class);
Or this one:
fieldValorPrevistoReal = new NumberField();
fieldValorPrevistoReal.setPropertyEditor(new NumberPropertyEditor(BigDecimal.class));Neither of them seem to solve the problem.
How do I get GXT to support BigDecimal??
BTW: using GXT 2.0.1 and GWT 1.7.