get fileUpload Link in java Bean

UI Components for JSF
Post Reply
dislodrum
Posts: 1
Joined: 27 Mar 2012, 16:28

27 Mar 2012, 16:40

Hi,

I'm new in the forum and this is my first post.

I'm using the last version of PrimeFaces.

I'm trying to use p:fileupload and set the file in the backbean but it doesn't work!!

The user click on browse button and a window pop to choose a file on his computer. As soon as he chooses the file, I can see the link but it doesn't set the file in the backbean. I want to be able to copy the choosen file on the server.

I've try to do that:

Code: Select all

<h:form enctype="multipart/form-data">
	<p:fileUpload  value="#{documentationBean.file}" mode="simple"/>
	<p:commandButton value="Submit" ajax="false" actionListener="#{documentationBean.upload}"/>
</h:form>
I've set the web.xml for filter as the doc says.

I've set "private UploadedFile file;" in the java bean and the getter and setter with an upload method.

Code: Select all

public void upload() {
   //code
}
As soon as I choose the file when I click on browse button, I can see the link of the file but it doesn't set the file in the java bean!!

I hope I'm clear about what I'm trying to do.
If anybody can help, that'd be great.

Maybe you'll think about another solution, I'm completely stuck here.

Cheers

Hamsterbau
Posts: 409
Joined: 28 Dec 2011, 17:44

27 Mar 2012, 23:01

1. You should search for FileUploadListener.
2. You have not posted your bean code, so nobody knows - except you - in which scope you configured your bean.
3. Normal behaviour is a 2 click upload, or you have to configure auto="true" (or something similar).
Primefaces 8.0.7 (PF Extensions 8.0)
JSF: Mojarra 2.3.2 (Spec 2.3) - running on WildFly 22

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 46 guests