To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.
Using Vaadin 8, is it possible to bind a property to multiple fields, where each field contributes to the value?
For example, a TextField and a ComboBox<Month> can be used to enter a java.time.MonthDay?
Or should this always be combined in a custom Field<MonthDay> ? The disadvantage of a custom field is that it adds another <div> which is not always desirable if you want to treat each field as separate fields similar to others in CSS (for example when using a flexbox layout with space-between, when you want each field in a separate slot in a verticallayout, ...).
A late reply, but in case it is of use to anyone: If you need this pattern in multiple locations, I'd recommend creating a custom HasValue<MonthDay> for this to support things like validating the fields together (there is no 30th of February). It is of course possible to perform cross-field validation etc. without doing so, but that can complicate the code using these fields.
One way to have a custom HasValue in Vaadin Framework 8.1 without linking the fields in layout is to make a Composite (containing one of the fields and managing another field that is not inside it layout-wise) that implements HasValue<MonthDay>, and encapsulate management of the "sub-fields" in it.