Binding Data to Forms
Flow provides a class that the developer can use to define how the values in a business object should be bound to the fields shown in the user interface. Binder
takes care of reading values from the business object and converting the user’s data between the format expected by the business object and the format expected by the field. The input entered by the user can also be validated, and the current validation status can be presented to the user in different ways.
The first step to binding fields for a form is to create a and bind some input fields. There is only one Binder
instance for each form and it is used for all fields in that form.
When we have bound field components using our binder, we can use the binder to load values from a person into the field, let the user edit the values and finally save the values back into a person instance.
Java
The above example uses Java 8 method references for defining how field values are loaded and saved. It is also possible to use a lambda expression or an explicit instance of the callback interface instead of a method reference.
Java
Java