View Full Version : NullPointerException for Menu.hide()

9 Mar 2011, 7:36 AM

I'm getting the exception:

java.lang.NullPointerException: null at com.extjs.gxt.ui.client.widget.menu.Menu.hide(Menu.java:284) at com.extjs.gxt.ui.client.widget.menu.Item.handleClick(Item.java:162) at com.extjs.gxt.ui.client.widget.menu.Item.onClick(Item.java:172) at com.extjs.gxt.ui.client.widget.menu.CheckMenuItem.onClick(CheckMenuItem.java:199) at com.extjs.gxt.ui.client.widget.menu.Menu.onClick(Menu.java:684)

when I click on a menu item:


I would blame it on my coding, however the exceptions occurs in IE, but not in Firefox.

I can see in the debugger that the null pointer in Menu.java:284:


because of parentMenu is null. However, parentItem.parent is not null and is of type Menu.

I'm using GXT 2.2.1 and GWT 2.1.0.

What can be the reason for it not to work in IE, but in FF?

Thank you,


9 Mar 2011, 12:18 PM
The easiest would be if you would post your code that shows the issue in a small standalone testcase implementing EntryPoint

22 Sep 2013, 12:29 AM
I am using gxt2.2.5-gwt22.

This is definitely a bug. In Item class, there is a protected parentMenu field, but no where is this field settable. When a menu adds an menuItem, the menuItem does not automatically add the parentMenu. Even if you want to do it explicitly, there is no setter to use.

the work around is to subclass MenuItem and add setParentMenu(parentMenu) method.