好的,所以这听起来似乎是我的错误,也许是,但请先阅读问题:
我在vaadin中创建了一个表,该表由一系列自定义对象填充。我用来初始化我的表的方法与我用新值更新表格的方法相同:
public void fillTable(List<Order> orders, final User user)
{
this.removeAllItems();
for(final Order order : orders)
{
final Item currentItem = this.addItem(order);
currentItem.getItemProperty("musterId").setValue(order.getMusterId());
currentItem.getItemProperty("name").setValue(order.getName());
currentItem.getItemProperty("status").setValue(cb);
currentItem.getItemProperty("user").setValue(order.getUserName());
currentItem.getItemProperty("lab").setValue(order.getLab().getName());
currentItem.getItemProperty("supplier").setValue(order.getSupplier() == null ? "" : order.getSupplier().getName());
currentItem.getItemProperty("amount").setValue(order.getAmount());
currentItem.getItemProperty("date").setValue(order.getTimeStamp());
currentItem.getItemProperty("arrivalDate").setValue(order.getArrivalDate());
currentItem.getItemProperty("comment").setValue(comment);
}
}
我稍微过滤了这个方法,因为我初始化了两个要在表中显示的UI元素(cb,这是一个ComboBox和注释,它是一个TextField)。
现在,问题在于,只要我用相同的数据刷新表(或者不同,不重要),我就会得到一个&#34;无法将对象转换为数字&#34; -Exception for对于收到的第一个对象,amount-column的类型为double(amount的值为1.0)。我通过vaadin-sources进行了调试,我发现只有在某个时刻,vaadin试图从属性中获取值并返回一个空字符串,从而触发转换异常。问题是:为什么返回一个空字符串,为什么在初始写入表时不会触发此错误。
我做了一个解决方法,一旦我必须刷新它就创建一个新表,将旧表从布局中删除,但那......这是一件可怕的事情!这是一个vaadin bug吗?我做错了吗?
编辑:这是堆栈跟踪:
com.vaadin.ui.Table$CacheUpdateException: Error during Table cache update. Additional causes not shown.
at com.vaadin.ui.Table.maybeThrowCacheUpdateExceptions(Table.java:1767)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1756)
at com.vaadin.ui.Table.refreshRowCache(Table.java:2691)
at com.vaadin.ui.Table.containerItemSetChange(Table.java:4587)
at com.vaadin.data.util.AbstractContainer.fireItemSetChange(AbstractContainer.java:242)
at com.vaadin.data.util.AbstractInMemoryContainer.fireItemsAdded(AbstractInMemoryContainer.java:1012)
at com.vaadin.data.util.AbstractInMemoryContainer.fireItemAdded(AbstractInMemoryContainer.java:994)
at com.vaadin.data.util.IndexedContainer.fireItemAdded(IndexedContainer.java:627)
at com.vaadin.data.util.IndexedContainer.addItem(IndexedContainer.java:274)
at com.vaadin.ui.AbstractSelect.addItem(AbstractSelect.java:905)
at de.company.ui.components.tables.OrderTable.fillTable(OrderTable.java:85)
at de.company.ui.pages.OrderPage$1.valueChange(OrderPage.java:79)
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)
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:1008)
at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:1159)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:570)
at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:732)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:468)
at com.vaadin.ui.ComboBox.changeVariables(ComboBox.java:730)
at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:603)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:422)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:273)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:79)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1409)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:769)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1667)
at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:172)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1650)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:497)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:610)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:539)
at java.lang.Thread.run(Thread.java:745)
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:110)
at com.vaadin.data.util.converter.AbstractStringToNumberConverter.convertToPresentation(AbstractStringToNumberConverter.java:35)
at com.vaadin.ui.Table.formatPropertyValue(Table.java:4172)
at com.vaadin.ui.Table.getPropertyValue(Table.java:4114)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2386)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2225)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1745)
... 54 more