Hi!
I am using Primefaces 3.3. I need to use two fileUploads in advanced mode inside one form. The problem that I encounter is that when I upload some file using the first fileUpload it seems that the second fileUpload gets also activated since it shows the same file name to upload, although I don't click on the second fileUpload.
How can I solve this problem?
Thanks in advance.
Two fileUploads inside one form
- andyba
- Expert Member
- Posts: 2473
- Joined: 31 Mar 2011, 16:27
- Location: Steinfeld, near Bremen/Osnabrück, DE
- Contact:
You need to publish your code.nurzhan.izbassov wrote:Hi!
I am using Primefaces 3.3. I need to use two fileUploads in advanced mode inside one form. The problem that I encounter is that when I upload some file using the first fileUpload it seems that the second fileUpload gets also activated since it shows the same file name to upload, although I don't click on the second fileUpload.
How can I solve this problem?
Thanks in advance.
You need to read the User Guide.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
-
- Posts: 4
- Joined: 13 Jun 2012, 07:54
Facing similar issue. Going to look around the user guide bu the mean time please share if any suggestions!
Tomcat 6.0.32, JAVA5, Primefaces 3.2, windows 7,
Below is My view
And Below is my bean methods
Tomcat 6.0.32, JAVA5, Primefaces 3.2, windows 7,
Below is My view
Code: Select all
<h:form enctype="multipart/form-data">
<p:growl id="messages" showDetail="true" showSummary="true" sticky="true"/>
<p:fileUpload id="upload1" fileUploadListener="#{fileUploadBean.handleFileUpload1}"
mode="advanced" label="file1"
auto="true" immediate="true"
sizeLimit="1000000"
update="messages"
allowTypes="/(\.|\/)(xml)$/" />
<p:fileUpload id="upload2" fileUploadListener="#{fileUploadBean.handleFileUpload2}"
mode="advanced" label="file2"
auto="true"
sizeLimit="1000000"
update="messages"
allowTypes="/(\.|\/)(xml)$/" />
</h:form>
And Below is my bean methods
Code: Select all
public void handleFileUpload1(FileUploadEvent event) {
System.out.println("****Starting File Upload ****");
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("First File ", event.getFile().getFileName() + " is uploaded."));
context.addMessage(null, new FacesMessage("Second Message", "Additiona1 Info Here..."));
System.out.println("**** File Upload End ****");
}
public void handleFileUpload2(FileUploadEvent event) {
System.out.println("****Starting File Upload ****");
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Second File", event.getFile().getFileName() + " is uploaded."));
context.addMessage(null, new FacesMessage("Second Message", "Additional Info Here..."));
System.out.println("**** File Upload End ****");
}
}
-
- Posts: 5
- Joined: 26 Jun 2012, 10:48
Multiple advanced uploaders in same form is not supported at the moment.
refer the primefaces 3.3 pdf pageno :182
refer the primefaces 3.3 pdf pageno :182
You can vote for the issue here: http://code.google.com/p/primefaces/iss ... il?id=3274
- andyba
- Expert Member
- Posts: 2473
- Joined: 31 Mar 2011, 16:27
- Location: Steinfeld, near Bremen/Osnabrück, DE
- Contact:
I have seen a lot of posts about having multiple file uploads in the same form and I ask myself why?
Having more than one on a page can be justified sure but in the same form?
You can easily split them up across multiple forms even inside the same page.
I would also recommend using different beans dependent on where and why files are being uploaded.
You can reduce DRY conflicts by using a suitable superclass to handle the donkey work and extend them for each bean.
The reason I suggest this is because so many people try packing everything into one bean (where at least 2 are recommended, one request bean as receiver and either a session, view or conversation bean to track things after the uploads are finished) and end up with a mass of event methods, file properties and hardcoded dross.
Having more than one on a page can be justified sure but in the same form?
You can easily split them up across multiple forms even inside the same page.
I would also recommend using different beans dependent on where and why files are being uploaded.
You can reduce DRY conflicts by using a suitable superclass to handle the donkey work and extend them for each bean.
The reason I suggest this is because so many people try packing everything into one bean (where at least 2 are recommended, one request bean as receiver and either a session, view or conversation bean to track things after the uploads are finished) and end up with a mass of event methods, file properties and hardcoded dross.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now