我可以在Stackoverflow上参考现有问题:Error during Table cache update in vaadin
首先要做的事情是:我正在使用在Apache Tomcat v7.0上运行的Vaadin 7.5.2。
由于某些神奇的原因(我真的不明白我的常用代码之间有什么区别)vaadin表上的addItem函数给了我一个异常(“缓存更新期间出错”)。有一个内在的例外以及如下:
com.vaadin.ui.Table$CacheUpdateException: Error during Table cache update.
at com.vaadin.ui.Table.maybeThrowCacheUpdateExceptions(Table.java:1732)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1721)
at com.vaadin.ui.Table.refreshRowCache(Table.java:2654)
at com.vaadin.ui.Table.containerItemSetChange(Table.java:4540)
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.Table.addItem(Table.java:2616)
at com.flowfact.store.components.OrderListComponent.updateInformation(OrderListComponent.java:83)
at com.flowfact.store.components.OrderListComponent.setOrders(OrderListComponent.java:104)
at com.flowfact.store.FFStoreController.updateCustomerInfoOrders(FFStoreController.java:202)
at com.flowfact.store.FFStoreController.updateCustomerInfoOrders(FFStoreController.java:192)
at com.flowfact.store.components.CustomerInfoComponent$3.orderStatusChanged(CustomerInfoComponent.java:121)
at com.flowfact.store.components.OrderStatusSelectionComponent$1$1.response(OrderStatusSelectionComponent.java:60)
at com.flowfact.store.components.ConfirmationDialog.buttonClick(ConfirmationDialog.java:84)
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:601)
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:1003)
at com.vaadin.ui.Button.fireClick(Button.java:393)
at com.vaadin.ui.Button$1.click(Button.java:61)
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:601)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:313)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:202)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:95)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:350)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
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:4125)
at com.vaadin.ui.Table.getPropertyValue(Table.java:4067)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2349)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2188)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1710)
... 54 more
一些代码
OrderListComponent.java:83
private void updateInformation() {
Table orderTable = getOrderTable();
orderTable.setCacheRate(0.0);
orderTable.select(null);
orderTable.setValue(null);
orderTable.removeAllItems();
orderTable.clear();
for (Order order : getOrders()) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Product product = order.getProduct();
Object[] cells = new Object[] { product.getName(), simpleDateFormat.format(order.getCreationDate()),
simpleDateFormat.format(order.getUpdateDate()), order.getOrderStatus().toString(),
order.getPrice() };
orderTable.addItem(cells, new Integer(orderTable.size()));
}
if (getOrders().size() > 8) {
orderTable.setPageLength(8);
}
}
CustomerInfoComponent.java:121
orderStatusSelection = new OrderStatusSelectionComponent(getController(), new OrderStatusChangedListener() {
@Override
public void orderStatusChanged(OrderStatus status) {
if (getSelectedOrder().getProduct().getName().startsWith("happy") && status == OrderStatus.ACTIVE
&& getController().checkForEquivalentProduct("happy")) {
Notification.show(
"Sie haben bereits eine Bestellung dieser Art. Deaktivieren Sie diese, bevor Sie fortfahren.");
orderStatusSelection.setValue(OrderStatus.CANCELED.getValue());
} else {
getSelectedOrder().setOrderStatus(status);
getController().updateOrder(getSelectedOrder());
getController().updateCustomerInfoOrders();
}
}
}, getSelectedOrder().getProduct().getName().startsWith("happy"));
我的订单表初始化如下
orderTable = new Table("Bestellungen");
orderTable.addContainerProperty(COLUMN_NAME, String.class, "");
orderTable.addContainerProperty(COLUMN_CREATION_DATE, String.class, "");
orderTable.addContainerProperty(COLUMN_LAST_MODIFIED_DATE, String.class, "");
orderTable.addContainerProperty(COLUMN_STATUS, String.class, "");
orderTable.addContainerProperty(COLUMN_PRICE, Float.class, "");
orderTable.setPageLength(4);
orderTable.setSizeFull();
orderTable.setColumnReorderingAllowed(true);
orderTable.setColumnCollapsingAllowed(true);
orderTable.setColumnReorderingAllowed(true);
orderTable.setSelectable(true);
orderTable.setMultiSelect(false);
orderTable.setNullSelectionItemId(null);
我真的希望有人可以帮助我;
我完全陷入困境..
答案 0 :(得分:1)
price列的默认值无效 - 它应该与列类型相同,而不是String。尝试:
orderTable.addContainerProperty(COLUMN_PRICE, Float.class, null);
或
orderTable.addContainerProperty(COLUMN_PRICE, Float.class, 0f);