/**
   * This method writes a <noop/> to the response.
   *
   * @param context the FacesContext
   * @throws IOException
   */
  public static void renderNoopResponse(FacesContext context) throws IOException {
    ExternalContext external = context.getExternalContext();
    Writer writer = ExternalContextUtils.getResponseWriter(external);
    Object response = external.getResponse();

    if (response instanceof HttpServletResponse) {
      HttpServletResponse httpResponse = (HttpServletResponse) response;

      // Prevent caching
      httpResponse.setHeader("Cache-Control", "no-cache");
      httpResponse.setHeader("Pragma", "no-cache");
      httpResponse.setHeader("Expires", "-1");
    }

    XmlResponseWriter xrw = new XmlResponseWriter(writer, "utf-8");
    xrw.startDocument();

    xrw.startElement("partial-response", null);
    xrw.startElement("noop", null);
    xrw.endElement("noop");
    xrw.endElement("partial-response");

    xrw.endDocument();
    xrw.close();
  }
 /** @return true if portlet mode. */
 private boolean isPortletMode() {
   if (logger.isDebugEnabled()) {
     logger.debug("Mode detected in Application");
   }
   FacesContext fc = FacesContext.getCurrentInstance();
   portletMode = ExternalContextUtils.isPortlet(fc.getExternalContext());
   if (logger.isDebugEnabled()) {
     if (portletMode) {
       logger.debug("Portlet mode detected");
     } else {
       logger.debug("Servlet mode detected");
     }
   }
   return portletMode;
 }