Action equality

I have a table where I have successfully enabled right-click menu Actions. In my handleAction method in the Action.Handler, I am finding that this test for action equality:

if (action == ACTION_EDIT)

or this one:

if ACTION_EDIT.equals(action)

does not work. Instead I have to use:

if (action.getCaption().equals(ACTION_EDIT.getCaption()))

Any ideas why the first test (which works in the vaadin demos) might not be working?


static final Action ACTION_EDIT = new Action("Edit");
static final Action ACTION_SAVE_CHANGE = new Action("Save Change");
static final Action ACTION_CANCEL = new Action("Cancel");
static final Action[] ACTIONS = new Action[]


	table_1.addActionHandler(new Action.Handler() {
		public Action[] getActions(Object target, Object sender) {
			return ACTIONS;

		public void handleAction(Action action, Object sender, Object target) {
			//if (action.getCaption().equals(ACTION_EDIT.getCaption())) {
			if (action == ACTION_EDIT) {
			} else if (ACTION_SAVE_CHANGE.equals(action)) {

			} else if (ACTION_CANCEL.equals(action)) {


I think its caused by serialization and deserialization of the application state. This gives different instances, that use the default Object.equals().
I extended action, generate random field and overidden equals to use this field to compare instances. Works for me.