Exemplo n.º 1
0
  /*
   * (non-Javadoc)
   * @see
   * org.exoplatform.webui.core.UIPortletApplication#processRender(org.exoplatform
   * .webui.application.WebuiApplication,
   * org.exoplatform.webui.application.WebuiRequestContext)
   */
  public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception {
    PortletRequestContext pContext = (PortletRequestContext) context;
    PortletMode newMode = pContext.getApplicationMode();
    PortletPreferences preferences = pContext.getRequest().getPreferences();
    Boolean sharedCache = "true".equals(preferences.getValue(ENABLE_CACHE, "true"));

    if (context.getRemoteUser() == null
        || (Utils.isLiveMode()
            && sharedCache
            && !Utils.isPortalEditMode()
            && Utils.isPortletViewMode(pContext))) {
      WCMService wcmService = getApplicationComponent(WCMService.class);
      pContext
          .getResponse()
          .setProperty(MimeResponse.EXPIRATION_CACHE, "" + wcmService.getPortletExpirationCache());
      if (log.isTraceEnabled())
        log.trace("SCV rendering : cache set to " + wcmService.getPortletExpirationCache());
    }

    if (!newMode.equals(mode)) {
      activateMode(newMode);
      mode = newMode;
    }

    Node nodeView = null;
    if (uiPresentation != null) {
      nodeView = uiPresentation.getNodeView();
      if (nodeView != null) {
        TemplateService templateService = getApplicationComponent(TemplateService.class);
        uiPresentation
            .getChild(UIPresentation.class)
            .setTemplatePath(templateService.getTemplatePath(nodeView, false));
      }
    }

    if (uiPresentation != null && uiPresentation.isContextual() && nodeView != null) {
      RenderResponse response = context.getResponse();
      Element title = response.createElement("title");
      title.setTextContent(uiPresentation.getTitle(nodeView));
      response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, title);
    }

    if (context.getRemoteUser() != null && WCMComposer.MODE_EDIT.equals(Utils.getCurrentMode())) {
      pContext.getJavascriptManager().loadScriptResource(ResourceScope.SHARED, "content-selector");
      pContext.getJavascriptManager().loadScriptResource(ResourceScope.SHARED, "quick-edit");
    }

    setId(UISingleContentViewerPortlet.class.getSimpleName() + pContext.getWindowId());
    super.processRender(app, context);
  }
Exemplo n.º 2
0
 public static String getRealPortletId(PortletRequestContext portletRequestContext) {
   String portletId = portletRequestContext.getWindowId();
   int modeState = Util.getUIPortalApplication().getModeState();
   switch (modeState) {
     case UIPortalApplication.NORMAL_MODE:
       return portletId;
     case UIPortalApplication.APP_BLOCK_EDIT_MODE:
       return "UIPortlet-" + portletId;
     case UIPortalApplication.APP_VIEW_EDIT_MODE:
       return "EditMode-" + portletId;
     default:
       return null;
   }
 }
Exemplo n.º 3
0
 /**
  * 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);
   }
 }