[SOLVED] pdf download via <p:fileDownload> returns htm-file

UI Components for JSF
Post Reply
SimonSezz
Posts: 18
Joined: 02 Mar 2011, 13:47
Location: Germany

07 Mar 2012, 17:30

Hello everybody,

I tried to create a simple mobile page with an <p:fileDownload> function.

Everytime I click the button on my PC (Firefox 10.*) a download-dialog appears an I'm able to save the file to disc.

When I try the same on my mobile device (SGS II) with different browser (built-in, Opera, Dolphin hd) I only get an *.htm download.
Only Mozilla Firefox (mobile) seems to be able to save the file correctly. :shock:

I'm not sure whats the reason for this and I don't want to blame the Primefaces library but I'm stuck at this and hope to get some clues from the community.

Thanks in advance!


This is my view.xhtml

Code: Select all

<f:view xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pm="http://primefaces.org/mobile"
      contentType="text/html"
      encoding="UTF-8">
    
      <pm:page title="Download">
      	<pm:view>
      		<pm:content>
      		  <h:form id="hform">      			
      			...
      			<p:commandButton  value="Download" ajax="false" disabled="#{viewBean.invalidCode}">
						<p:fileDownload value="#{viewBean.file}"/>
				</p:commandButton>
			  </h:form>
      		</pm:content>
      	</pm:view>
      </pm:page>
</f:view>
I've used the DefaultStreamedConten(InputStream, contentType, name)-Method and set the contentType differently to "application/force-download", "application/download", "application/octet-stream", "application/pdf",...

My server is an Tomcat 7 with Mojarra 2.1.6 running Primefaces Core 3.1.1 and Mobile 0.9.1.

Once again, any help would be appreciated!
Last edited by SimonSezz on 03 Jul 2012, 16:16, edited 1 time in total.
Using:
Glassfish Application Server V3.1.2
Primefaces Library 3.4RC1 / 3.4 FINAL
Sun Mojarra 2.1.1

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Mar 2012, 14:19

Have you tried fileDownload live example on showcase with these browsers? Not sure if problem is mobile, fileDownload itself or these mobile browsers.

SimonSezz
Posts: 18
Joined: 02 Mar 2011, 13:47
Location: Germany

11 Mar 2012, 18:01

optimus.prime wrote:Have you tried fileDownload live example on showcase with these browsers? Not sure if problem is mobile, fileDownload itself or these mobile browsers.
Sorry for not checking back!

No, I've not checked the live example before but did just now.
Unfortunaly with the same result. Dolphin HD is able to resolve the file name but delivers an unopenable file "downloaded_optimus.jpg" (which represents an .htm-file wich is openable with the proper app).
The built-in browser opens the built-in download manager and shows a file called "download_optimus.htm".
So its the same behavior as before :( .

It would be great if there is any solution in doing this with any streamed content because the only workaround would be a <a href=""> solution and I don't want to go this route if I can avoid it.

Thanks for your effort!
Using:
Glassfish Application Server V3.1.2
Primefaces Library 3.4RC1 / 3.4 FINAL
Sun Mojarra 2.1.1

SimonSezz
Posts: 18
Joined: 02 Mar 2011, 13:47
Location: Germany

12 Mar 2012, 15:37

For whom it may concern :D :

I've also posted a detailed question on Stack Overflow just to increase my chances of getting help.

I hope I dind't do something wrong by linking this post!

Thanks for your effort!
Using:
Glassfish Application Server V3.1.2
Primefaces Library 3.4RC1 / 3.4 FINAL
Sun Mojarra 2.1.1

maxtorzito
Posts: 96
Joined: 19 Jan 2011, 17:00

30 Mar 2012, 04:46

I tested the filedownload in showcase with my mobile device (HTC EVO 4G - Android), and have the same "issue", i get a downloaded_optimus.jpg file but i cant see it

Primefaces 5.0
Primefaces Extensions 1.2.1
Omnifaces 1.8.1
JDK 1.7.0_25
MyFaces 2.1.15
Ubuntu
Apache TomEE 1.7.0 JAX-RS

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

03 Apr 2012, 16:36

maxtorzito wrote:I tested the filedownload in showcase with my mobile device (HTC EVO 4G - Android), and have the same "issue", i get a downloaded_optimus.jpg file but i cant see it
I have same mobile device and looking forward to developing mobile xhtml pages and testing on this device. the other person did not list the expected test results in initial topic above. What are the expected test results. Posting on stackoverflow is fine.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

SimonSezz
Posts: 18
Joined: 02 Mar 2011, 13:47
Location: Germany

03 Jul 2012, 16:15

I know its a bit late but the problem is solved!

Have a look at this for further informations.

@smithh032772
I don't know if I was addressed but the expected result was to download a pdf-file in my environment and in case of the showcase I expected a jpeg-file, both openable on ANY mobile device.

Cheers!
Using:
Glassfish Application Server V3.1.2
Primefaces Library 3.4RC1 / 3.4 FINAL
Sun Mojarra 2.1.1

zuzullo
Posts: 1
Joined: 08 Apr 2014, 13:37

08 Apr 2014, 13:40

Sorry but I cannot find the solution.
I tried all browsers but all retrive me an htm file intead of PDF.

please help

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 47 guests