fileupload validation problem , file becomes null

UI Components for JSF
Post Reply
ankitamehta
Posts: 1
Joined: 13 Sep 2014, 23:00

13 Sep 2014, 23:19

I am using primefaces 4.0 with websphere 8.5.I am just doing simple file upload

<h:form enctype="multipart/form-data" id="frm">
<p:fileUpload id="uploadFile" value="#{backingbean.file}" mode="simple" />

<p:commandButton id="save" value="save" action="#{backingbean.save}" update="@form" ajax="false">
</p:commandButton>
</h:form>
I have to put a warning if uploaded file is not a recommended type which could be doc,xls etc.But if it is not that type then i have to throw a warning message but User can still save the file.So in the backingbean save method I am checking the file type and throwing the warning message.When i press save button, it goes to the backingbean save method checks the file type and throws the warning message.But the uploaded file becomes blank.I want the file to be there so that user can ignore the warning and save it and the user does not have to choose the file again.

I am not sure if it is the default behavior that the file becomes blank/null when the form loads back after submitting.

Thanks
Ankita

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

16 Sep 2014, 16:20

Mode simple uploads require that you save the file during the upload request. If you need an additional step to confirm that the file be kept, delete the file if the user doesn't want to keep it.
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

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 48 guests