Reputation: 456
I have a form with two fields:
<h:form>
<p:fileUpload fileUploadListener="#{mybean.fileUpload}" mode="advanced" auto="true" />
<h:inputText value="#{mybean.discription}"/>
<h:commandButton action="#{mybean.submit}" value="Submit"/>
</h:form>
If the file is large, it needs some seconds to upload completely. The form don't use ajax. To be a user, i choose a file (large file) then click submit button immediately. What happens with the file, null or submit method wait until file to be uploaded completety? Thanks.
Upvotes: 0
Views: 370
Reputation: 452
I think it is important to understand how really the file will be uploaded by p:fileUpload component. It will be done in one of two ways: it will create a hidden separate form put the input type="file" there and submit this form or it will use flash to upload the file which also doesn't use original form.
All this means that it can not be synchronized in browser and when you click submit button it will not wait until the file is uploaded.
Still it can be synchronized on the server. If you use JBoss Seam than probably method calls will be synchronized(as far as I rememeber jboss seam synchronizes ajax requests on server side). If you use some other framework(Spring) than it won't be syncronized and it can happen that #{mybean.submit} will be called earlier than #{mybean.fileUpload} or even the state on the server can be lost and #{mybean.fileUpload} won't be called at all.
But in any case the file will be uploaded to the server but can be ignored by the bean.
Upvotes: 1