public void execute(Event<UIPortlet> event) throws Exception {
      UIPortlet uiPortlet = event.getSource();

      UIPortalApplication uiPortalApp = uiPortlet.getAncestorOfType(UIPortalApplication.class);
      UIWorkingWorkspace uiWorkingWS =
          uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
      PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
      pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
      pcontext.ignoreAJAXUpdateOnPortlets(true);

      String windowState = null;

      Object changeWindowStateAttribute =
          event.getRequestContext().getAttribute(CHANGE_WINDOW_STATE_EVENT);
      if (changeWindowStateAttribute != null && changeWindowStateAttribute instanceof String) {
        windowState = (String) changeWindowStateAttribute;
      }

      if (windowState == null) {
        windowState = event.getRequestContext().getRequestParameter(Constants.PORTAL_WINDOW_STATE);
      }
      if (windowState == null) {
        if (event.getRequestContext().getRequestParameter(UIComponent.OBJECTID) != null) {
          windowState = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID).trim();
        }
      }

      if (windowState == null) {
        windowState = uiPortlet.getCurrentWindowState().toString();
      }

      UIPage uiPage = uiPortlet.getAncestorOfType(UIPage.class);
      if (windowState.equals(WindowState.MAXIMIZED.toString())) {
        if (uiPage != null) {
          uiPage.normalizePortletWindowStates();
          uiPage.setMaximizedUIPortlet(uiPortlet);
        }
        uiPortlet.setCurrentWindowState(WindowState.MAXIMIZED);
        return;
      } else {
        if (windowState.equals(WindowState.MINIMIZED.toString())) {
          uiPortlet.setCurrentWindowState(WindowState.MINIMIZED);
        } else {
          uiPortlet.setCurrentWindowState(WindowState.NORMAL);
        }
        if (uiPage != null) {
          clearMaximizedUIComponent(uiPage, uiPortlet);
        }
      }
    }
  /**
   * This method is used to set the next portlet window state if this one needs to be modified
   * because of the incoming request
   */
  public static void setNextState(UIPortlet uiPortlet, WindowState state) {
    if (state != null) {
      UIPage uiPage = uiPortlet.getAncestorOfType(UIPage.class);

      if (WindowState.MAXIMIZED.equals(state)) {
        if (uiPage != null) {
          uiPage.normalizePortletWindowStates();
          uiPage.setMaximizedUIPortlet(uiPortlet);
          uiPortlet.setCurrentWindowState(WindowState.MAXIMIZED);
        }
      } else if (WindowState.MINIMIZED.equals(state)) {
        uiPortlet.setCurrentWindowState(WindowState.MINIMIZED);
        if (uiPage != null) {
          clearMaximizedUIComponent(uiPage, uiPortlet);
        }
      } else {
        uiPortlet.setCurrentWindowState(WindowState.NORMAL);
        if (uiPage != null) {
          clearMaximizedUIComponent(uiPage, uiPortlet);
        }
      }
    }
  }