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 request 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With