
package de.ivu.elect.jee.presentation.menu;

import java.io.Serializable;

import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
import javax.inject.Named;

import org.primefaces.event.MenuActionEvent;

/**
 * Idee: http://forum.primefaces.org/viewtopic.php?f=3&t=34560
 */
@Named(MenuItemActionListenerController.COMPONENT_NAME)
public class MenuItemActionListenerController implements Serializable {

  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "menuItemActionListenerController";

  public MenuItemActionListenerController() {
    super();
  }

  public String event(ActionEvent event) {
    IVUDefaultMenuItem defaultMenuItem = (IVUDefaultMenuItem) ((MenuActionEvent) event).getMenuItem();

    for (ActionListener actionListener : defaultMenuItem.getActionListeners()) {
      actionListener.processAction(event);
    }

    return null;
  }
}
