Package javax.portlet

Examples of javax.portlet.MimeResponse


      }
      cookies = null;
    }

    if (isMimeResponse) {
      MimeResponse mimeResponse = (MimeResponse) response;
      ResourceResponse resourceResponse = isResourceResponse ? (ResourceResponse) response : null;

      if (locale != null) {
        try {
          resourceResponse.setLocale(locale);
        }
        catch (UnsupportedOperationException usoe) {
          // TODO: temporary "fix" for JBoss Portal which doesn't
          // yet
          // support this
          // (although required by the Portlet API 2.0!)
        }
      }

      if (contentType != null) {
        if (characterEncoding != null) {
          if (setContentTypeAfterEncoding) {
            resourceResponse.setCharacterEncoding(characterEncoding);
            resourceResponse.setContentType(contentType);
          }
          else {
            resourceResponse.setContentType(contentType);
            resourceResponse.setCharacterEncoding(characterEncoding);
          }
        }
        else {
          mimeResponse.setContentType(contentType);
        }
      }
      else if (characterEncoding != null) {
        resourceResponse.setCharacterEncoding(characterEncoding);
      }

      if (headers != null) {
        for (Map.Entry<String, ArrayList<String>> entry : headers.entrySet()) {
          for (String value : entry.getValue()) {
            mimeResponse.addProperty(entry.getKey(), value);
          }
        }
        headers = null;
      }

      if (isResourceResponse && hasStatus) {
        resourceResponse.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(statusCode));
      }

      if (isResourceResponse && contentLength > -1) {
        try {
          resourceResponse.setContentLength(contentLength);
        }
        catch (UnsupportedOperationException usoe) {
          // TODO: temporary "fix" for JBoss Portal which doesn't
          // yet
          // support this
          // (although required by the Portlet API 2.0!)
        }
      }
    }

    if (!hasError && !closed && redirectLocation == null && isMimeResponse) {
      MimeResponse mimeResponse = (MimeResponse) response;

      if (outputStream != null) {
        outputStream.flush();
        byteOutputBuffer.writeToAndClose(mimeResponse.getPortletOutputStream());
      }
      else if (printWriter != null) {
        printWriter.flush();
        charOutputBuffer.writeToAndClose(mimeResponse.getWriter());
      }
    }

    if (outputStream != null) {
      outputStream.close();
View Full Code Here


      }

      public void renderURL(PropertyMap properties, MimeType mimeType, Appendable appendable) throws IOException {

        if (resp instanceof MimeResponse) {
          MimeResponse mimeResp = (MimeResponse)resp;

          //
          ControllerHandler handler = bridge.getApplication().resolveBean(ControllerService.class).getDescriptor().getMethodByHandle(target);

          //
          BaseURL url;
          if (handler.getPhase() == Phase.ACTION) {
            url = mimeResp.createActionURL();
          } else if (handler.getPhase() == Phase.VIEW) {
            url = mimeResp.createRenderURL();
          } else if (handler.getPhase() == Phase.RESOURCE) {
            url = mimeResp.createResourceURL();
          } else {
            throw new AssertionError();
          }

          // Set generic parameters
View Full Code Here

  private static final long serialVersionUID = -591128176912990631L;

  public String getRenderUrl() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    MimeResponse mimeResponse = (MimeResponse) externalContext.getResponse();
    PortletURL renderURL = mimeResponse.createRenderURL();
    renderURL.setParameter("testParam", new String[] { "foo", "bar" });

    return renderURL.toString();
  }
View Full Code Here

  @Override
  public String getResponseCharacterEncoding() {

    if (portletResponse instanceof MimeResponse) {
      MimeResponse mimeResponse = (MimeResponse) portletResponse;
      String characterEncoding = mimeResponse.getCharacterEncoding();

      if (manageIncongruities) {
        incongruityContext.setResponseCharacterEncoding(characterEncoding);
      }
View Full Code Here

  @Override
  public String getResponseContentType() {

    if (portletResponse instanceof MimeResponse) {

      MimeResponse mimeResponse = (MimeResponse) portletResponse;

      String responseContentType = mimeResponse.getContentType();

      if (responseContentType == null) {
        responseContentType = portletRequest.getResponseContentType();
      }
View Full Code Here

  @Override
  public Writer getResponseOutputWriter() throws IOException {

    if (responseOutputWriter == null) {

      MimeResponse mimeResponse = (MimeResponse) portletResponse;

      if (portletPhase == Bridge.PortletPhase.RENDER_PHASE) {

        if (renderRedirectEnabled == null) {
          renderRedirectEnabled = PortletConfigParam.RenderRedirectEnabled.getBooleanValue(portletConfig);
        }

        if (renderRedirectEnabled) {
          responseOutputWriter = new RenderRedirectWriterImpl(mimeResponse.getWriter());
        }
        else {
          responseOutputWriter = mimeResponse.getWriter();
        }

      }
      else {
        responseOutputWriter = mimeResponse.getWriter();
      }

    }

    return responseOutputWriter;
View Full Code Here

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {

    ExternalContext externalContext = facesContext.getExternalContext();
    MimeResponse mimeResponse = (MimeResponse) externalContext.getResponse();
    Map<String, Object> attributes = uiComponent.getAttributes();
    PortletURL portletURL = (PortletURL) mimeResponse.createResourceURL();
    ResourceURL resourceURL = (ResourceURL) portletURL;
    String id = (String) attributes.get(StringPool.ID);
    String cacheability = (String) attributes.get("cacheability");

    try {
View Full Code Here

public class RenderURLRenderer extends PortletURLRenderer {

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
    ExternalContext externalContext = facesContext.getExternalContext();
    MimeResponse mimeResponse = (MimeResponse) externalContext.getResponse();
    PortletURL renderURL = mimeResponse.createRenderURL();
    super.encodeEnd(facesContext, uiComponent, renderURL);
  }
View Full Code Here

  public void flushBuffer() throws IOException {
    PortletResponse portletResponse = getWrapped();

    if (portletResponse instanceof MimeResponse) {
      MimeResponse mimeResponse = (MimeResponse) portletResponse;
      mimeResponse.flushBuffer();
    }
    else {
      throw new UnsupportedOperationException();
    }
  }
View Full Code Here

  public void reset() {
    PortletResponse portletResponse = getWrapped();

    if (portletResponse instanceof MimeResponse) {
      MimeResponse mimeResponse = (MimeResponse) portletResponse;
      mimeResponse.reset();
    }
    else {
      throw new UnsupportedOperationException();
    }
  }
View Full Code Here

TOP

Related Classes of javax.portlet.MimeResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.