I’m having a few issues transitioning from Vaadin 6 Forms to Vaadin 7 FieldGroup. I’ve got a few ideas in mind and would like to know if these are the right approaches. I’m using Vaadin 7.0.0.rc1, Runo for my theme, and CustomLayout with BeanFieldGroup to create Validators from my bean annotations.
Field validation icons (!) show up when the form is initially rendered with empty fields.
Previously the icons only showed when a field lost focus or the form was submitted. To recreate this I plan to iterate over the fields and set setValidationVisible to false. Then add focus listeners on each field to commit on blur. If an error happens then setValidationVisible to true. Same goes for the Submit button.
@NotNull required fields do not display the * icon
Not sure on where to go with this one
Nested properties are not validated.
Here I plan to create several BeanFieldGroups, one for the original bean and one for each nested bean.
Fields are not spaced apart from each other.
Looks like setSpacing is gone. I’ll add some CSS for this.
Validation error messages are not displayed in the form.
When I catch commit errors I’ll update a label I insert in CustomLayout.
Still no solution for validation messages? It is really annoying, what would be the use case of showing error messages when form is initially rendered?
binder = new BeanFieldGroup<ContaEmpresa>(ContaEmpresa.class);
binder.setFieldFactory(new CustomFieldFactory());
ContaEmpresa bean = controller.getCurrentBean();
binder.setItemDataSource(bean);
TextField nomeTextField = (TextField) binder.buildAndBind("Seu nome", "nome");
TextField empresaTextField = (TextField) binder.buildAndBind("Nome da sua Empresa", "empresa.nomeFantasia");
The first text field (the validation errors are fired on a binder.commit() call)
But the second one, with a nested property, the validation errors are not fired. The problem is that the nested entity cant be saved, because we have validation errors, that are not handled by UI because i cant find a way to solve this with BeanFieldGroup. Not even adding a new BeanValidator to the textField
Validation error messages are not displayed in the form.
For this I listen for blur events on all my fields, validate the entire form from top to bottom, then use the exception message in an error label.
[/quote]
After create a FieldGroup, do ‘buildAndBind()’ for all the FieldGroup fields; and add ‘BeanValidator’ for all of ones;
I’d created a ‘MyPersonalBlurListener implements BlurListener’ class.
I’m able to commit and validate/get error in the field;
But I’m unable to call validate() method in my fieldGruop, the commit method should be done it.
So I not understood how to catch exception message for every single validate field.
I still have deprecated Forms, and what I see is that the discard() method doesn’t work any more – info is being written to the bean item immediately. I haven’t found a way to stop that (and am now trying to figure out field groups and what happened to the factory methods that passed a prop id).
Are you also seeing an immediate write-through issue with Form or is it working for you?