O'Reilly logo

Vaadin 7 UI Design By Example Beginner's Guide by Alejandro Duarte

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Context menus

A context menu appears when the user right-clicks some component. Vaadin supports context menus for Table, Tree, and TreeTable. Menu options are encapsulated using Action instances:

final Action action = new Action("Say hello");

To add actions and respond to them, we must add a Handler. A Handler is an interface with two methods:

public interface Handler extends Serializable {

  public Action[] getActions(Object target, Object sender);

  public void handleAction(Action action, Object sender,
      Object target);

}

getActions must return an array containing all the actions we want to show in our context menu. handleAction will be called when an action is performed (the user clicks a menu item). Here is an example implementation that shows a somewhat ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required