Hello,

How can i exclude the response of a download-action for the
extension-filter?

My bean write the result directly to the faces-response:

private boolean writeOutContent(final HttpServletResponse res, final
File content, final String theFilename) {
    boolean result = true;
    if (content != null) {
      try {
        res.reset();
        final WritableByteChannel writeChannelOut =
Channels.newChannel(res.getOutputStream());
        final ReadableByteChannel readChannelIn =
Channels.newChannel(new FileInputStream(content));
        res.setHeader("Pragma", "no-cache");
        res.setDateHeader("Expires", 0);
        // set content type so that the browser shows xml filter in save
dialog
        res.setContentType("text/xml");
        res.setHeader("Content-disposition", "attachment; filename=" +
theFilename);
        ChannelTools.fastChannelCopy(readChannelIn, writeChannelOut);
      } catch (final IOException e) {
        result = false;
      }
    } else {
      result = false;
    }
    return result;
  }

  private String download() {
    final FacesContext facesContext = FacesContext.getCurrentInstance();
    writeOutContent(getServletResponse(), new File(this.filename),
getFilename());
    facesContext.responseComplete();
    return null;
  }

I found these lines in ExtensionFilter:

public boolean isValidContentType(String contentType)
    {
        return contentType.startsWith("text/html") ||
                contentType.startsWith("text/xml") ||
                contentType.startsWith("application/xhtml+xml") ||
                contentType.startsWith("application/xml");
    }

I must return a text/xml but i dont want filter the content with the
extension-filter. Is this possible?

My web.xml:

<filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <servlet-name>FacesServlet</servlet-name>
  </filter-mapping>
  <filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>*.jsf</url-pattern>
  </filter-mapping>

Regards
hoehmi

Reply via email to