Hi Everybody,
I have a basic problem with Form. Tried to solve this, but could not figure it out. I need your help. Here is my problem:-
I have a Form with a data source attached to it. I am trying to update the data in the form. On click of update button, I am first calling Form.commit() and then updating the bean in database. It works fine, except in one case. There is a field of Integer type in bean class. If I don’t give any value to this field then throwing following error.
14:41:05,346 ERROR [de.mte.dialog.RefDataDialog]
(http–0.0.0.0-8080-6) Failed to modify instance (null): com.vaadin.data.Buffered$SourceException
at com.vaadin.ui.Form.commit(Form.java:365) [vaadin-6.8.2.jar:6.8.2]
at de.mte.dialog.RefDataDialog.doOkAction(RefDataDialog.java:311) [classes:]
at de.mte.dialog.RefDataDialog.buttonClick(RefDataDialog.java:255) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_31]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_31]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_31]
at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_31]
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.ui.Button.fireClick(Button.java:567) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.ui.Button.changeVariables(Button.java:223) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1460) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1404) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1329) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:761) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:318) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501) [vaadin-6.8.2.jar:6.8.2]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]
Caused by: com.vaadin.data.Buffered$SourceException
at com.vaadin.ui.AbstractField.commit(AbstractField.java:273) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.ui.Form.commit(Form.java:339) [vaadin-6.8.2.jar:6.8.2]
... 32 more
Caused by: com.vaadin.data.Property$ConversionException: java.lang.reflect.InvocationTargetException
at com.vaadin.data.util.MethodProperty.convertValue(MethodProperty.java:695) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.data.util.MethodProperty.setValue(MethodProperty.java:664) [vaadin-6.8.2.jar:6.8.2]
at com.vaadin.ui.AbstractField.commit(AbstractField.java:268) [vaadin-6.8.2.jar:6.8.2]
... 33 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedConstructorAccessor121.newInstance(Unknown Source) [:1.6.0_31]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [rt.jar:1.6.0_31]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [rt.jar:1.6.0_31]
at com.vaadin.data.util.MethodProperty.convertValue(MethodProperty.java:692) [vaadin-6.8.2.jar:6.8.2]
... 35 more
Caused by: java.lang.NumberFormatException: For input string: “”
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) [rt.jar:1.6.0_31]
at java.lang.Integer.parseInt(Integer.java:470) [rt.jar:1.6.0_31]
at java.lang.Integer.<init>(Integer.java:660) [rt.jar:1.6.0_31]
... 39 more
Why is it taking empty string? Or how should I handle this if I have to use Form.commit() ? I don’t want to check the value
of each field before commit.
Related to this I have one more question. My update method can throw an exception. On exception I have to revert the changes in bean, that happened because of Form.commit() call?
Thanks in advance!