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

      String portletMode = null;

      Object changePortletModeAttribute =
          event.getRequestContext().getAttribute(CHANGE_PORTLET_MODE_EVENT);
      if (changePortletModeAttribute != null && changePortletModeAttribute instanceof String) {
        portletMode = (String) changePortletModeAttribute;
      }

      if (portletMode == null) {
        portletMode = event.getRequestContext().getRequestParameter(Constants.PORTAL_PORTLET_MODE);
      }
      if (portletMode == null) {
        portletMode = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
      }
      if (portletMode == null) {
        portletMode = uiPortlet.getCurrentPortletMode().toString();
      }

      log.trace(
          "Change portlet mode of " + uiPortlet.getPortletContext().getId() + " to " + portletMode);
      if (portletMode.equals(PortletMode.HELP.toString())) {
        uiPortlet.setCurrentPortletMode(PortletMode.HELP);
      } else if (portletMode.equals(PortletMode.EDIT.toString())) {
        uiPortlet.setCurrentPortletMode(PortletMode.EDIT);
      } else if (portletMode.equals(PortletMode.VIEW.toString())) {
        uiPortlet.setCurrentPortletMode(PortletMode.VIEW);
      } else {
        PortletMode customMode = new PortletMode(portletMode);
        uiPortlet.setCurrentPortletMode(customMode);
      }
      event.getRequestContext().addUIComponentToUpdateByAjax(uiPortlet);
    }
  @Override
  public void actionURL(long plid, String portletName, String queryString) throws Exception {

    String windowState = WindowState.NORMAL.toString();
    String portletMode = PortletMode.VIEW.toString();

    actionURL(windowState, portletMode, plid, portletName, queryString);
  }
  @Override
  protected void writeAjaxPage(
      RenderRequest request, RenderResponse response, Window window, Application application)
      throws IOException, MalformedURLException, PortletException {
    MailApplication mailApplication = (MailApplication) application;

    // user is set in the portlet listener by the application
    if (mailApplication.getController().getUser() == null) {
      // normally, the portal takes care of this
      // this branch is in case the user has not been registered in the controller
      writeNotLoggedInPageHtml(request, response, window);
    } else if (PortletMode.VIEW.equals(request.getPortletMode())
        && WindowState.NORMAL.equals(request.getWindowState())) {
      mailApplication.writeViewPageHtml(request, response, window);
    } else {
      // this includes other modes as well as the maximized state
      super.writeAjaxPage(request, response, window, application);
    }
  }
 /**
  * Activate mode.
  *
  * @param newMode the mode
  * @throws Exception the exception
  */
 public void activateMode(PortletMode newMode) throws Exception {
   if (getChild(UIPresentationContainer.class) != null) {
     removeChild(UIPresentationContainer.class);
   }
   if (getChild(UISCVPreferences.class) != null) {
     removeChild(UISCVPreferences.class);
   }
   if (PortletMode.VIEW.equals(newMode)) {
     PortletRequestContext pContext =
         (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
     uiPresentation =
         addChild(
             UIPresentationContainer.class,
             null,
             UIPresentationContainer.class.getSimpleName() + pContext.getWindowId());
   } else if (PortletMode.EDIT.equals(newMode)) {
     popPreferences = addChild(UISCVPreferences.class, null, null);
     popPreferences.setInternalPreferencesMode(true);
   }
 }
Exemple #5
0
 /**
  * Check if the portlet current mode is view mode or not
  *
  * @param pContext The request context of a portlet
  * @return return true if current portlet mode is view mode; otherwise return false
  */
 public static boolean isPortletViewMode(PortletRequestContext pContext) {
   return PortletMode.VIEW.equals(pContext.getApplicationMode());
 }