Unexpected error using fileUpload component

UI Components for JSF
Post Reply
liukvar
Posts: 43
Joined: 21 Oct 2009, 09:52

17 Dec 2014, 17:06

Hi
I am using PrimeFaces 5.1.6 (Elite)

When using fileUpload component file object (org.primefaces.model.UploadedFile) is always null. :cry:

I have created a single page like this http://www.primefaces.org/showcase/mobi ... Page.xhtml

Removing the tag <f:view renderKitId="PRIMEFACES_MOBILE" /> everything work properly.

In web.xml I have:

Code: Select all

<context-param>
		<param-name>primefaces.UPLOADER</param-name>
		<param-value>native</param-value>
	</context-param>
Using Firebug I noticed this difference:

page with <f:view renderKitId="PRIMEFACES_MOBILE" /> => file always null
Request Header from Upload Stream
Content-Length 1586786
Content-Type multipart/form-data; boundary=---------------------------20773183922614

page without <f:view renderKitId="PRIMEFACES_MOBILE" /> => file org.primefaces.model.NativeUploadedFile
Request Header from Upload Stream
Content-Length 1586644
Content-Type multipart/form-data; boundary=---------------------------1506631681792


Any ideas on this?

Best regards
Luca Vargetto
PrimeFaces 5.1.6
Mojarra 2.2.8
WildFly 8.2
Eclipse Luna
JDK 8

MarkWinton
Posts: 50
Joined: 18 Oct 2013, 23:40

07 Jan 2015, 01:48

I'm seeing the same behaviour too running a 5.2 snapshot from a couple of days ago - I've not done the firebug checks that you have, but the UploadedFile in the backing bean is always null.

Non-mobile page using the same backing bean works no problems.

As a sanity check I reverted to PF 5.1, and the UploadedFile is populated correctly there, so this does seem to be something introduced since then.

Application server is Glassfish 4.1, using the default version of JSF that comes with that.

necsydev
Posts: 2
Joined: 07 Jul 2014, 09:39

23 Jan 2015, 10:45

I have the same problem (tried with PF 5.1.8 and 5.1.1).
BTW, mode="advanced" seems not supported (almost graphically).
I checked the official documentation but nothing is wrote about PF Mobile fileUpload and about which mode is supported.
Primeface Mobile Showcase only shows a silly example with mode="simple"
I can not believe that Primefaces is so buggy.
If I delete the line:

Code: Select all

<f:view renderKitId="PRIMEFACES_MOBILE" />
the graphical result is weird but it works.

Liukvar, have you solved the problem or did you use alternatives to Primefaces?

Bye.

Marco

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	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">
<f:view renderKitId="PRIMEFACES_MOBILE" />
<h:head>
	<link rel="stylesheet" type="text/css" href="../resources/css/app.css"></link>
</h:head>
<h:body>

	<pm:page>	
		<pm:header title="Upload">
		</pm:header>	
		<pm:content>
				
				<h:form enctype="multipart/form-data">
						<p:growl showDetail="true"/>
					    <p:fileUpload value="#{fileUploadController.file}" mode="simple"/>
    					<p:commandButton value="Upload" icon="ui-icon-arrow-u" ajax="false" actionListener="#{fileUploadController.upload}"/>
    			</h:form>
                   				
		</pm:content>
	</pm:page>

</h:body>
</html>

RElliott
Posts: 94
Joined: 07 Feb 2014, 00:39

17 Feb 2015, 19:42

I resolved this issue in my application by switching to the <h:inputFile> tag as as shown below:

Code: Select all

<h:inputFile
    id="file"
    value="#{fileUpload.file}"
    required="true"
    requiredMessage="File is required."
    label="File" />
<p:commandButton
        value="Submit"
        ajax="false"
        action="#{fileUpload.upload}" />
See the following tutorial for details: http://www.javatutorials.co.in/jsf-2-2- ... inputfile/.
PrimeFaces 7.0.1, Glassfish 5.1.0, Oracle JDK 8, Eclipse 2016-02

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 46 guests