I have a wicket form containing a FileUploadField
and some more text fields. When a mandatory field is missing, the validation correctly fails. Then, the file I chose for the upload becomes empty, so I have to select it one more time before submitting the form with all required fields filled out.
In fact, the FileUploadField
documentation says:
The model of this component is reset with null at the end of the reque开发者_C百科st because FileUpload instances do not survive across requests since the input streams they point to will be closed. Because of this, the FileUpload instance should be processed within the same request as the form containing it was submitted.
Is there a way to keep the selected file when the form validation fails?
No. The problem is that the browser refreshes it, and for (browser) security reasons, you cannot set the default value on file fields.
精彩评论