Why don't work ContextMenu addon in vaadin 6.8.1

Hi all,

I want use context menu addon in my tree component. The tree component has own context menu but it isn’t flexible. Please let me show my code and I will ask my question.

final ContextMenu menu = new ContextMenu();
ContextMenuItem myitem = menu.addItem( "MyItem" );
ContextMenuItem myitem2 = menu.addItem( "MyItem2" );

menu.addListener( new ContextMenu.ClickListener(){

    public void contextItemClick( org.vaadin.peter.contextmenu.ContextMenu.ClickEvent event ){
        logger.info( "Clicked Item: {}", event.getClickedItem().getName() );

} );

treeMenu.setDebugId( "mytreemenu" );

this.addListener( new LayoutEvents.LayoutClickListener(){

    public void layoutClick( LayoutClickEvent event ){
        // TODO Auto-generated method stub
        if( LayoutClickEvent.BUTTON_RIGHT == event.getButton() ){
            logger.info( "x, y: {}, {}", event.getClientX(), event.getClientY() );
            logger.info( "Menu: {}", menu );

            menu.setEnabled( true );

            // menu.show( event.getClientX(), event.getClientY() );
            menu.show( treeMenu );
} );

This code must show a context menu but dont working.

Please help meeeeeee…


Hello, with Vaadin 6 you’ll have to add the context menu to some layout before using it. Add the context menu for example to your main layout before using it with the tree. In Vaadin 7 you can directly extend a component with context menu.

I made like this. But there is an another problem now.

Widgetset does not contain implementation for org.vaadin.peter.contextmenu.ContextMenu. Check its @ClientWidget mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions. Unrendered UIDL:
-Unrendered UIDL
-org.vaadin.peter.contextmenu.ContextMenu(NO CLIENT IMPLEMENTATION FOUND) id=PID51 show=true component_locator=mytreemenu left=0 top=0
-item id=0 name=MyItem enabled=true style= separator=false
-item id=1 name=MyItem2 enabled=true style= separator=false


Have you compiled the widgetset? Widgetset must also be mentioned in the web.xml. Please refer to
from Book of Vaadin chapter 16.2.2.

Basically what you need to do is introduce the widgetset parameter in the web.xml as your servlet’s init-param with name “widgetset” and have the param-value to point to your compilation of the widgetset, which is the folder under WebContent/VAADIN/widgetsets/

Widgetset you can compile most easily with Vaadin eclipse plugin which you can download from Eclipse Marketplace or directly from the download section of our site.


I have the same problem. I created the context menu, which if I give exact x,y coordinates, shows up properly and works fine. But if I want to position the menu to a component (like to a marker - simple Marker which I add to an OpenLayersMap) displays nothing.
Unfortunately event.getClientX() method runs NPE. See: http://code.google.com/p/vopenlayers/issues/detail?id=125
Am I missing something? How can I reach the mouse coordinates to position the context menu?
I’m working with context menu 3.0.1 and vaadin 6.8.11.

        public void click(MouseEvents.ClickEvent event) {
            ContextMenu c = createContextMenu(); 

            VerticalLayout vl = new VerticalLayout();

//          getWindow().addComponent(c);
//          map.addComponent(c);


Tried this way, but didn’t work:

        public void click(MouseEvents.ClickEvent event) {
            ContextMenu c = createContextMenu();


Thanks in advance!