protected void doHeaders(RenderRequest request, RenderResponse response) {
    super.doHeaders(request, response);
    PortalContext portalContext = request.getPortalContext();
    String portalInfo = portalContext.getPortalInfo();

    // -- adding DOM element to head is supported by JetSpeed 2.2
    if (portalInfo.contains(Constants.JETSPEED)) {
      // -- add CSS
      Element cssElement = response.createElement("link");
      // --encoding URLs is important
      cssElement.setAttribute(
          "href", response.encodeURL((request.getContextPath() + "/css/bookCatalog.css")));
      cssElement.setAttribute("rel", "stylesheet");
      cssElement.setAttribute("type", "text/css");
      response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, cssElement);

      // -- add JavaScript
      Element jsElement = response.createElement("script");

      // --encoding URLs to resources is important
      jsElement.setAttribute(
          "src", response.encodeURL((request.getContextPath() + "/js/bookCatalog.js")));
      jsElement.setAttribute("type", "text/javascript");
      response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, jsElement);
    }
  }
  /*
   * (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);
  }