Binder.writeBean should have an option to keep the 'hasChanges' flag
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
Right now, Binder.writeBean() resets the internal hasChanges flag so that any consequent calls to Binder.hasChanges() return false. That prevents using Binder to implement the 'edit / preview / back' pattern where 'edit' and 'preview' views are implemented in different components so that a bean has to be passed from one to another.
Consider the following use case:
OrderBean order = service.getOrder(); // a JPA entity
OrderEditor editor = new OrderEditor(); // the 'edit' component
OrderViewer viewer = new OrderViewer(); // the 'preview' component
editor.addReviewButtonClickListener(e -> {
// after this line the binder in the `editor` component would think it's clean
editor.writeBean(order);
viewer.open(order);
});
viewer.addBackButtonClickListener(e -> {
viewer.close(); // get back to the editor
});
editor.addCancelButtonClickListener(e -> {
if (editor.isDirty()) {
/* [request a user confirmation to discard unsaved changes] */
// When getting to this point via 'edit' -> 'cancel'
// `editor.isDirty()` would be the same as `editor.getBinder().isDirty()`
// When getting to this point via 'edit' -> 'review' -> 'back' -> 'cancel'
// the editor's binder is useless
}
});
editor.open(order);
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 at the Binder.writeBean() and Binder.hasChanges() entry points described in the issue. Define how an option should preserve the hasChanges flag, then verify the edit → review → back → cancel flow still detects unsaved changes while existing write behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100