• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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
 
Skool. Stay in. Smartness. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic