aspose file tools*
The moose likes JSF and the fly likes Ajax4Jsf Filter interfering when contentType is set to 'application/pdf' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Ajax4Jsf Filter interfering when contentType is set to Watch "Ajax4Jsf Filter interfering when contentType is set to New topic
Author

Ajax4Jsf Filter interfering when contentType is set to 'application/pdf'

Augustine Chelliah
Greenhorn

Joined: Mar 12, 2009
Posts: 28
Hello all,
I have a requirement where i need to click a command link and a PDF file to be opened in a new window. The path of the PDF file is to be taken from a database. So in the backing bean, I get the path, set the contentType to 'application/pdf' and of course writing to a new byte steam. When i run it , a new window opens but the file does not get displayed.... when i checked the logs, I think Ajax4JSF is interfering with this process..... check out the below logs..

[WebContainer : 4] DEBUG org.ajax4jsf.framework.ajax.AjaxContext - Process component tree for collect used scripts and styles
2009-08-05 04:54:22,478 [WebContainer : 4] DEBUG org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlResponseWriterImpl - No content type given, using default content type text/html
2009-08-05 04:54:22,478 [WebContainer : 4] DEBUG org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlResponseWriterImpl - No character encoding given, using default character encoding ISO-8859-1
2009-08-05 04:54:22,478 [WebContainer : 4] DEBUG org.ajax4jsf.framework.renderer.AjaxPhaseListener - Process after phase RENDER_RESPONSE(6)
2009-08-05 04:54:22,478 [WebContainer : 4] DEBUG org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter - create HTML/XML parser for content type: application/pdf
2009-08-05 04:54:22,478 [WebContainer : 4] DEBUG org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter - Parser not have support for the such content type, send response as-is

Why does it say no content type given when I have explicitly set the content type ?
Has anybody faced this...??


Thanks & Regards,
Augustine
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

If you're trying to get a PDF straight from a JSF view, you're asking for trouble. JSF is expecting to output HTML. All you'll accomplish if you attempt to override the rendering process like that is frustration.

A more workable approach is to use a servlet or (non-JSF) JSP to render the PDF in the same way you would in a non-JSF application. Then put a URL reference to this servlet/JSP on your JSF view definition.

JSF isn't an exclusive platform. You can (and should) mix JSF and non-JSF request handlers when it makes sense to do so.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax4Jsf Filter interfering when contentType is set to 'application/pdf'