Hello, I have a problem (Version 24.6.4) using a MultiSelectComboBox (as well as a CheckboxGroup) with a CollaborationBinder in a dialog. After opening the dialog, a setValue
with an empty set is called again on the MultiSelectComboBox.
I have created a minimal example with a very simple bean (A), which has an attribute of type Set<Double>
. In the dialog, I have also added a TextField
to show that this field does not have any issues. Additionally, I have created a few buttons that clearly demonstrate the problem.
After opening the dialog, you can use “Print A” to display the current state of the topic. At this point, the object contains exactly one Double
in the set. The MultiSelectComboBox correctly displays this as well. However, if you click on “Print Value Select”, you will see that the value of the MultiSelectComboBox is empty at that moment. The values in the TextField
remain correct.
If you then trigger a “Write bean”, the set in the object is incorrectly cleared. This issue does not occur outside of a dialog. I couldn’t find any restrictions regarding my approach in the documentation.
Thanks in advance!
@Getter
@Setter
@ToString
public class A {
private String name;
private Set<Double> bs = new HashSet();
public A(String name) {
this.name = name;
}
public void addB(Double b) {
this.getBs()
.add(b);
}
}
// Create some Objects
A a = new A("A1");
Double d1 = Double.valueOf(1);
Double d2 = Double.valueOf(2);
Double d3 = Double.valueOf(3);
a.addB(d1);
List<Double> allBs = new ArrayList<Double>();
allBs.add(d1);
allBs.add(d2);
allBs.add(d3);
// Init MultiSelectComboBox
MultiSelectComboBox<Double> multiSelectComboBox = new MultiSelectComboBox<>();
multiSelectComboBox.setLabel("Bs");
multiSelectComboBox.setItems(allBs);
// Init TextField
TextField textField = new TextField("Name");
// Init CollabortionBinder
CollaborationBinder<A> binder = new CollaborationBinder<A>(A.class, GlobalManagement.getUserInfo());
binder.forField(multiSelectComboBox, Set.class, Double.class)
.bind("bs");
binder.forField(textField)
.bind("name");
// Create Dialog
Dialog myDialog = new Dialog();
myDialog.add(multiSelectComboBox);
myDialog.add(textField);
// Add Button to print Object A
Button printAButton = new Button("Print A");
printAButton.addSingleClickListener(click -> {
System.out.println(a);
});
myDialog.add(printAButton);
// Add Button to print current values from the MultiSelectComboBox
Button printValueSelect = new Button("Print Value Select");
printValueSelect.addSingleClickListener(click -> {
System.out.println(multiSelectComboBox.getValue());
});
myDialog.add(printValueSelect);
// Add Button to print current value of the TextField
Button printTextField = new Button("Print TextField");
printTextField.addSingleClickListener(click -> {
System.out.println(textField.getValue());
});
myDialog.add(printTextField);
// Add Button to write bean
Button write = new Button("Write bean");
write.addSingleClickListener(click -> {
try {
binder.writeBean(a);
System.out.println("Bean written");
} catch (ValidationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
myDialog.add(write);
// Add Button to set topic manually again
Button setTopicButton = new Button("Set topic");
setTopicButton.addSingleClickListener(click -> {
binder.setTopic("ID123", () -> a);
});
myDialog.add(setTopicButton);
// Set topic
binder.setTopic("ID123", () -> a);
// Open dialog
myDialog.open();