-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing binding does not remove all references #3405
Comments
I'm sorry for providing such incomplete information but I can't get it working with replacing a binding for a field. I have checked out the combo-box-flow project and added a "card" where I can reproduce another error where the binding is not correctly removed. I think it is the client side that calls the server with an old binding reference. An important thing is that I'm calling Here is my code snippet with instructions how to get the error. private void createStringComboBoxWithBinder() {
Div message = createMessageDiv("string-selection-message-with-binder");
// begin-source-example
// source-example-heading: String selection with binder
// 1. Select 'Google Chrome'
// 2. Click 'Validate'
// 3. Clear selection
// 4. Click 'Not required'
// 5. Results in
// java.lang.NullPointerException: This Binding is no longer attached to a Binder
Song song = new Song();
Binder<Song> binder = new Binder<>();
ComboBox<String> comboBox = new ComboBox<>("Browsers");
comboBox.setItems("Google Chrome", "Mozilla Firefox", "Opera",
"Apple Safari", "Microsoft Edge");
comboBox.addValueChangeListener(event -> {
if (event.getSource().isEmpty()) {
message.setText("No browser selected");
} else {
message.setText("Selected browser: " + event.getValue());
}
});
NativeButton requiredButton = new NativeButton("Set required", e -> {
binder.removeBinding(comboBox);
Binder.Binding<Song, String> binding = binder.forField(comboBox)
.asRequired()
.bind(Song::getName, Song::setName);
binding.read(song);
});
NativeButton notRequiredButton = new NativeButton("Not required", e -> {
binder.removeBinding(comboBox);
Binder.Binding<Song, String> binding = binder.forField(comboBox)
.bind(Song::getName, Song::setName);
binding.read(song);
});
NativeButton validateButton = new NativeButton("Validate", e -> binder.validate());
binder.forField(comboBox)
.asRequired()
.bind(Song::getName, Song::setName);
binder.setBean(song);
// end-source-example
comboBox.getStyle().set(ElementConstants.STYLE_WIDTH, WIDTH_STRING);
comboBox.setId("string-selection-box-with-binder");
addCard("String selection with binder", requiredButton, notRequiredButton, validateButton, comboBox, message);
} |
This is a duplicate of #5384 which is already fixed. |
When removing a binding (for a field) from a binder I want the framework to remove references to that binding so that I can add a new binding for the same field.
When calling
Binder::removeBinding()
the binding is not removed from theSet<Binding<BEAN, ?>> changedBindings
. This results in a NPE when callingBinder::validate()
because it will call an unbinded binding. (update: I cannot reproduce this error anymore)The text was updated successfully, but these errors were encountered: