Ejemplo n.º 1
0
 /**
  * Override doDispatch method for handling custom portlet modes.
  *
  * @see javax.portlet.GenericPortlet#doDispatch(javax.portlet.RenderRequest,
  *     javax.portlet.RenderResponse)
  */
 protected void doDispatch(RenderRequest request, RenderResponse response)
     throws PortletException, IOException {
   if (!WindowState.MINIMIZED.equals(request.getWindowState())) {
     PortletMode mode = request.getPortletMode();
     if (CUSTOM_CONFIG_MODE.equals(mode)) {
       doCustomConfigure(request, response);
       return;
     }
   }
   super.doDispatch(request, response);
 }
Ejemplo n.º 2
0
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {

    if (WindowState.MINIMIZED.equals(request.getWindowState())) {
      return;
    }

    if (WindowState.NORMAL.equals(request.getWindowState())) {
      normalView.include(request, response);
    } else {
      maximizedView.include(request, response);
    }
  }
    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)) {
       uiPortlet.setCurrentWindowState(WindowState.MAXIMIZED);
       if (uiPage != null) {
         uiPage.setMaximizedUIPortlet(uiPortlet);
       }
     } else if (WindowState.MINIMIZED.equals(state)) {
       uiPortlet.setCurrentWindowState(WindowState.MINIMIZED);
       if (uiPage != null) {
         uiPage.setMaximizedUIPortlet(null);
       }
     } else {
       uiPortlet.setCurrentWindowState(WindowState.NORMAL);
       if (uiPage != null) {
         uiPage.setMaximizedUIPortlet(null);
       }
     }
   }
 }
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {

    long clock = System.currentTimeMillis();

    try {
      System.out.println("hi: " + clock);
      log.debug("Rendering view.");

      if (WindowState.MINIMIZED.equals(request.getWindowState())) {
        return;
      }

      if (WindowState.NORMAL.equals(request.getWindowState())) {
        normalView.include(request, response);
      } else {
        maximizedView.include(request, response);
      }
    } finally {
      long duration = System.currentTimeMillis() - clock;
      log.debug(String.format("View rendering took %s ms.", duration));
    }
  }
    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) {
        windowState = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID).trim();
      }

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

      UIPageBody uiPageBody = uiPortlet.getAncestorOfType(UIPageBody.class);
      UIPage uiPage = uiPortlet.getAncestorOfType(UIPage.class);
      if (windowState.equals(WindowState.MAXIMIZED.toString())) {
        if (uiPageBody != null) {
          uiPortlet.setCurrentWindowState(WindowState.MAXIMIZED);
          // TODO dang.tung: we have to set maximized portlet for page because in ShowMaxWindow case
          // the PageBody isn't rendered
          //                reference: UIPortalLifecycle, UIPageLifecycle, renderChildren() in
          // UIPageBody
          // ---------------------------------------------------------
          if (uiPage != null && uiPage.isShowMaxWindow()) {
            uiPage.setMaximizedUIPortlet(uiPortlet);
          }
          // ---------------------------------------------------------
          uiPageBody.setMaximizedUIComponent(uiPortlet);
        } else {
          uiPortlet.setCurrentWindowState(WindowState.NORMAL);
        }
        return;
      }
      if (uiPageBody != null) {
        UIPortlet maxPortlet = (UIPortlet) uiPageBody.getMaximizedUIComponent();
        if (maxPortlet == uiPortlet) {
          uiPageBody.setMaximizedUIComponent(null);
        }
      }
      // TODO dang.tung: for ShowMaxWindow situation
      // ----------------------------------------------------------------
      if (uiPage != null) {
        UIPortlet maxPortlet = (UIPortlet) uiPage.getMaximizedUIPortlet();
        if (maxPortlet == uiPortlet) {
          uiPage.setMaximizedUIPortlet(null);
        }
      }
      // -----------------------------------------------------------------
      if (windowState.equals(WindowState.MINIMIZED.toString())) {
        uiPortlet.setCurrentWindowState(WindowState.MINIMIZED);
        return;
      }
      uiPortlet.setCurrentWindowState(WindowState.NORMAL);
    }