Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Problem trying to send file to browser in JSF

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I've tried two different techniques for sending a file to a browser(making the user download a file). I've tried an example from myfaces wikipage


I have also tried using a component named fileDownload from PrimeFaces. Both give the same result:

I get a response from the server, the response contains text that should be in the file. The header is a follows:

X
To me this looks correct but for some reason I don't get to download the file, I just get this response in firebug.

Does anyone have any idea?, could it be a serversetting problem? I using glassfish 3

Thanks / Stefan
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try using "application/force-download" instead of "text/plain".

Regrds,
Prasenjit
 
Stefan Rasmusson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It didn't work. I think the problem lies in JSF and facelets. I use a facelet and a template.

Template



Facelet




But if I rewrite the facelet like this, the download works, and it works with the mimetype text/plain




Any ideas?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this.
response.setContentType("application/vnd.ms-word");

Because for the plain text some time browser displays content directly in the screen instead of giving download option.
 
Stefan Rasmusson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It figured out the problem.
I was using the primefaces commad button that does a partial ajax submit. Changed to jsf commandbutton and everything works
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic