Error Message on ComboBox on commit()

I have a ComboBox on a FormLayout
the ComboBox is loaded with Objects

            final ComboBox comboBox = new ComboBox("taxdeduct");

            ArrayList<YesNo> container = new ArrayList<YesNo>();

            container.add(new YesNo("1", "Yes"));
            container.add(new YesNo("0", "No"));

            comboBox.setContainerDataSource(CollectionContainer.fromBeans(container, true));
            comboBox.setItemCaptionMode(Select.ITEM_CAPTION_MODE_ID);
            comboBox.setItemCaptionPropertyId("name");
            comboBox.setNullSelectionAllowed(false);
            comboBox.setReadOnly(false);
            comboBox.setInvalidAllowed(false);
            comboBox.setNewItemsAllowed(false);
            comboBox.setImmediate(true);

Everything works fine with exception when I call super.commit();

When I excecute super.commit(); I get an error message

What does this error message mean?

Thank You

Peter

Here’s the error message:

com.vaadin.data.Property$ConversionException: java.lang.NoSuchMethodException: com.census.YesNo.(java.lang.String)
at com.vaadin.data.util.MethodProperty.setValue(MethodProperty.java:716)
at com.vaadin.ui.AbstractField.commit(AbstractField.java:242)
at com.vaadin.ui.Form.commit(Form.java:336)
at com.census.account.AccountForm.commit(AccountForm.java:270)
at com.census.account.AccountForm.buttonClick(AccountForm.java:178)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1154)
at com.vaadin.ui.Button.fireClick(Button.java:371)
at com.vaadin.ui.Button.changeVariables(Button.java:193)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1094)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:590)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:266)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:476)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoSuchMethodException: com.census.YesNo.(java.lang.String)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)
at com.vaadin.data.util.MethodProperty.setValue(MethodProperty.java:709)
… 42 more

I have the same problem, how you solved? Thanks.

This means that the class of the value being set for a property does not match the property type, so MethodProperty attempts to convert the value it gets into the correct type by trying to call a constructor for it with a String parameter (newValue.toString()). There is no such constructor for YesNo, so this fails.

I don’t really know CollectionContainer, but probably its getType() or the getType() method of its items does not return the correct type for the properties.

I would recommend using a BeanContainer in this case with suitable item IDs (e.g. Boolean.TRUE and Boolean.FALSE) in this case.