Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid FileUploadField reset at the end of the request in wicket

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?

like image 928
javanna Avatar asked Jul 06 '11 15:07

javanna


1 Answers

No. The problem is that the browser refreshes it, and for (browser) security reasons, you cannot set the default value on file fields.

like image 124
Ant Kutschera Avatar answered Sep 17 '22 02:09

Ant Kutschera