Bound bean is not updated when field listeners are called
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
If you have code like
Binder<OrderItem> binder = new Binder<>(OrderItem.class);
binder.forField(quantity).withConverter(converter).bind("quantity");
quantity.addValueChangeListener(e->{
System.out.println(e.getNewValue());
System.out.println(binder.getBean().getQuantity());
});
....
binder.setBean(new OrderItem());
you would assume that the both lines printed are the same, i.e. the bound bean is updated before the listener is triggered. This does not happen though, because the bound bean is always updated AFTER the listener is triggered. The root cause seems to be that BindingImpl.initFieldValue removes the listener added while binding the field, and re-adds it after the other listener.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading BindingImpl.initFieldValue and trace how the binding listener is removed and re-added around field listeners. Reproduce the issue with the Binder example, then verify that the bound bean is updated before the listener observes the value and add or update a regression test for that ordering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100