Composite Fields with CustomField
A composite field class must implement the getType() and initContent() methods. The latter should return the content composite of the field. It is typically a layout component, but can be any component.
It is also possible to override validate(), setInternalValue(), commit(), setPropertyDataSource, isEmpty() and other methods to implement different functionalities in the field. Methods overriding setInternalValue() should call the superclass method.
A custom switch button field
Java
We can now use the field in all the normal ways for a field:
BooleanField field = new BooleanField();
// ...and read the value
Label value = new Label(field.getValue()?
// ...and handle value changes
field.addValueChangeListener(event ->