gatanaso/multiselect-combo-box-flow

Items are not displayed as selected

jfexart opened this issue · 4 comments

I have a form where I incorporated this component and did the binding without any problem.

binder.forField(teamsComboBox).bind(Organization::getTeams, Organization::setTeams);

It works perfect. Save and display values correctly. But if I set the selected values programmatically. These are not shown as selected. The same thing happens that in this bug: Items are not shown as selected if set programmatically.

This allows you to select again the items that have already been loaded as values.

Vaadin version: 14.1.21
Multiselect-combo-box-flow version: 2.4.0
Java version: 11
Tested on: Google Chrome 80 and Firefox 74

Thanks for reporting this issue @jfexart. Have you implemented equals() and hashCode() for the Teams object? If not, could you please override those methods and give it another try?

Yes, I had annotated the class with @EqualsAndHashCode from lombok project

Okay, could you please provide a minimal reproducible example project I could look at? It would greatly help in identifying and resolving the issue. Thank you

If you are using Lombok, try to use Hash code and Equal on your class like bellow

@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class Page {
    @EqualsAndHashCode.Include
    private Long id;
    private String pageCode;

}

@EqualsAndHashCode(onlyExplicitlyIncluded = true) and @EqualsAndHashCode.Include important