• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...??
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic