我在我的项目中使用Vaadin 7.0.5和ContextMenu 4.2.1加载项。
我面临一个奇怪的问题。我已将附件附加到treetable上。当我对treetable进行多次右键单击时(即使菜单打开后),加载项会抛出异常。我得到以下例外:
com.vaadin.server.ServerRpcManager$RpcInvocationException: Unable to invoke method
itemClicked in org.vaadin.peter.contextmenu.client.ContextMenuServerRpc
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:170)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
at com.vaadin.server.AbstractCommunicationManager.handleBurst(AbstractCommunicationManager.java:1680)
at com.vaadin.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1566)
at com.vaadin.server.AbstractCommunicationManager.handleUidlRequest(AbstractCommunicationManager.java:582)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:315)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
at org.vaadin.artur.icepush.ICEPushServlet.service(ICEPushServlet.java:72)
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:947)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor109.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
... 24 more
Caused by: java.lang.NullPointerException
at org.vaadin.peter.contextmenu.ContextMenu$1.itemClicked(ContextMenu.java:46)
... 28 more
有人可以指导我吗?它在浏览器上弹出红色错误屏幕并且烦人吗?
代码示例
final ContextMenu tableContextMenu = new ContextMenu();
tableContextMenu.setAsTableContextMenu(builtTreeTable);
tableContextMenu.addContextMenuTableListener(new TableListener() {
@Override
public void onContextMenuOpenFromRow(ContextMenuOpenedOnTableRowEvent event) {
tableContextMenu.removeAllItems();
tableContextMenu.addItem("Item 1", new ThemeResource("img/Item_1.png")).addItemClickListener(new ContextMenuItemClickListener() {
@Override
public void contextMenuItemClicked(ContextMenuItemClickEvent event) {}
});
tableContextMenu.addItem("Item 2", new ThemeResource("img/Item_2.png")).addItemClickListener(new ContextMenuItemClickListener() {
@Override
public void contextMenuItemClicked(ContextMenuItemClickEvent event) {}
});
tableContextMenu.addItem("Item 3", new ThemeResource("img/Item_3.png")).addItemClickListener(new ContextMenuItemClickListener() {
@Override
public void contextMenuItemClicked(ContextMenuItemClickEvent event) {}
});
ContextMenuItem allocate = tableContextMenu.addItem("Item 4", new ThemeResource("img/Item_4.png"));
ContextMenuItem averagePrice = allocate.addItem("Item 4.1", new ThemeResource("img/Item_41.png"));
averagePrice.addItemClickListener(new ContextMenuItemClickListener() {
@Override
public void contextMenuItemClicked(ContextMenuItemClickEvent event) {}
});
ContextMenuItem manualAllocation = allocate.addItem("Item 4.2", new ThemeResource("img/Item_42.png"));
manualAllocation.addItemClickListener(new ContextMenuItemClickListener() {
@Override
public void contextMenuItemClicked(ContextMenuItemClickEvent event) {}
});
tableContextMenu.addItem("Item 5", new ThemeResource("img/Item_5.png")).addItemClickListener(new ContextMenuItemClickListener() {
@Override
public void contextMenuItemClicked(ContextMenuItemClickEvent event) {}
});
}
@Override
public void onContextMenuOpenFromHeader(ContextMenuOpenedOnTableHeaderEvent event) {
tableContextMenu.removeAllItems();
tableContextMenu.addItem("Header", new ThemeResource("img/Header.png")).addItemClickListener(new ContextMenuItemClickListener() {
@Override
public void contextMenuItemClicked(ContextMenuItemClickEvent event) {}
});
}
@Override
public void onContextMenuOpenFromFooter(ContextMenuOpenedOnTableFooterEvent event) {
tableContextMenu.removeAllItems();
}
});