Reputation: 751
I have a vaadin web application with fom VERY complex forms (100+ input components). The data is bound to the form using a binder. The form has a lot of validation rules (required fields, validation number ranges, comparing dates, ...). My Users sometime spend a whole lot of time in filling the form.
Is there a way to save the data from user input to database even if the validations fail? binder.writeBeanIfValid(myBean)
does only write the changes when no validation errors exist. And binder.writeBean(myBean)
throws an exception, when there are validation errors.
I have added an additional button to manually trigger the validation, because my users want to check their input while working in the form. But sometimes, filling the form takes so long that they want to interrupt input, save data and continue working on it the other day. That is why I would like to allow saving even if validation errors exist.
Upvotes: 1
Views: 784
Reputation: 10643
"Save as draft" was not really supported in Binder directly in older versions. What you would probably want is binder.writeBeanAsDraft (myBean,Boolean)
, which would write the bean with values passing the validators or everything passing conversion. First step of this was done in Vaadin 8.10 / Vaadin 14.1 and forced mode in Vaadin 8.11 and Vaadin 14.3.
Upvotes: 2