Add an item into an IndexedContainer causes exceptions

Hi, I’m new here and i’ve begun to learn about Vaadin, I’m writing a simple Programm and every time when I’m trying to add an Item into the IndexedContainer I’m getting the folowing Exception:

com.vaadin.server.DefaultErrorHandler doDefault SEVERE: com.vaadin.event.ListenerMethod$MethodException: Invocation of method valueChange in TableViewPartViewImpl$1 failed. at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:528) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161) at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:969) at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:1127) at com.vaadin.ui.AbstractField.setValue(AbstractField.java:542) at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:702) at com.vaadin.ui.AbstractSelect.changeVariables(AbstractSelect.java:521) at com.vaadin.ui.Table.changeVariables(Table.java:2880) at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:396) at com.vaadin.server.communication.ServerRpcHandler.handleBurst(ServerRpcHandler.java:221) at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:111) at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:91) at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37) at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1382) at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238) at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:370) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:667) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:724) Caused by: com.vaadin.ui.Table$CacheUpdateException: Error during Table cache update. Additional causes not shown. at com.vaadin.ui.Table.maybeThrowCacheUpdateExceptions(Table.java:1716) at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1705) at com.vaadin.ui.Table.refreshRowCache(Table.java:2639) at com.vaadin.ui.Table.containerItemSetChange(Table.java:4445) at com.vaadin.data.util.AbstractContainer.fireItemSetChange(AbstractContainer.java:242) at com.vaadin.data.util.IndexedContainer.fireItemAdded(IndexedContainer.java:623) at com.vaadin.data.util.IndexedContainer.addItem(IndexedContainer.java:272) at com.vaadin.data.util.IndexedContainer.addItem(IndexedContainer.java:256 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508) ... 41 more Caused by: java.lang.IllegalArgumentException: Cannot format given Object as a Number at java.text.DecimalFormat.format(DecimalFormat.java:505) at java.text.Format.format(Format.java:157) at com.vaadin.data.util.converter.AbstractStringToNumberConverter.convertToPresentation(AbstractStringToNumberConverter.java:109) at com.vaadin.data.util.converter.AbstractStringToNumberConverter.convertToPresentation(AbstractStringToNumberConverter.java:35) at com.vaadin.ui.Table.formatPropertyValue(Table.java:4053) at com.vaadin.ui.Table.getPropertyValue(Table.java:3995) at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2334) at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2173) at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1694) ... 55 more Here is my Code:

IndexedContainer ic = (IndexedContainer) detailTable.getContainerDataSource();
Object id = ic.addItem();
ic.getContainerProperty(id, ic.getContainerPropertyIds().toArray()[0]
).setValue(name);
ic.getContainerProperty(id, ic.getContainerPropertyIds().toArray()[1]
).setValue(date);

Caused by: java.lang.IllegalArgumentException: Cannot format given Object as a Number at java.text.DecimalFormat.format(DecimalFormat.java:505) at java.text.Format.format(Format.java:157) at com.vaadin.data.util.converter.AbstractStringToNumberConverter.convertToPresentation(AbstractStringToNumberConverter.java:109) at com.vaadin.data.util.converter.AbstractStringToNumberConverter.convertToPresentation(AbstractStringToNumberConverter.java:35) at com.vaadin.ui.Table.formatPropertyValue(Table.java:4053) at com.vaadin.ui.Table.getPropertyValue(Table.java:3995) at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2334) at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2173) at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1694) ... 55 more You try to add objects, that are not convertable to numbers, to a collection of numbers.
How is
ic
created?

First I initialize the detailTable:

private Table detailTable = new Table()

private void initDetailDataTable() { detailTable.setWidth("500px"); detailTable.setCaption("Detailtable:"); detailTable.setSelectable(true); IndexedContainer ic = new IndexedContainer(); ic.addContainerProperty("name", String.class, ""); ic.addContainerProperty("date", String.class, ""); detailTable.setContainerDataSource(ic); detailTable.setImmediate(true); } And the error causes in another method, where I try to add Items to the detailTable by (snd line):

IndexedContainer ic = (IndexedContainer) detailTable.getContainerDataSource(); Object id = ic.addItem(); Is there another way to add Items to an IndexedContainer or to a table, that is more clearer?

It looks, like some of the properties is
Number
not
String.

Try to debug the application to find, what value is causing the problem:
add a breakpont to
Table.java:3995
and check values for
rowId, colId
and
property.

Thanks for your help, I get it. The Exception was caused by the
defaultValue
of the Property. I inserted
Integer.class
as the[i]

[/i]Data type of the new Property[i]

[/i]with the
defaultValue

“”
, which doesn’t match. The settings are set up by Spring configuration and I didn’t pay attention :slight_smile:

for (int i = detailTable.getVisibleColumns().length; i < settings.getTableColumns().size(); i++) {
            ColumnDefinition definition = settings.getTableColumns().get(i);
            ic.addContainerProperty(definition.getLabel(), definition.getClazz(), [color=#FF0000]
[b]
""
[/b]
[/color]);
        }