0

got a weird issue, i have a primefaces command button :

<p:commandButton action="#{userBean.buttonToUploadText}" value="Submit" icon ="ui-icon-arrowstop-1-n"/> 

userBean.java

public String buttonToUploadText() {
    System.out.println("buttonToUploadText invoked"); //testing to make sure it is called
    return "/upload/uploadText.xhtml";
}

all this should do is simply take the user to the upload text page, it does this but whenever i have this button the fileupload does nothing, but the second i edit this command button out and use a normal one the file upload works perfect ? what am i doing wrong

EDIT:

have just found out when ajax is false it works perfectly, why is this ?

kolossus
  • 20,559
  • 3
  • 52
  • 104
user1924104
  • 891
  • 2
  • 16
  • 38

1 Answers1

2

You didn't show all the code, but this problem is recognizable if your PrimeFaces file upload component has a mode="simple". This will generate a native HTML <input type="file"> without any JS/Ajax support. This requires a command button with ajax="false", exactly as shown in the showcase.

If you want to be able to upload files and submit the form by ajax, then use mode="advanced". See also the showcase.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555