MyEclipse for Spring
Code Reference: CustomerEditor.java
The editor class owns the form state for the customer screen. This page describes its responsibilities and the events it handles.
CustomerEditor is the form state holder for the customer screen. It reads the record to edit, exposes the values to the view and collects the submitted values. It does not decide what to do with them. That decision belongs to the service that the editor calls on submit.
Responsibilities
- Load the record for an edit request, or create an empty record for a new entry.
- Expose the current values to the form view.
- Accept submitted values and hand them to the service.
- Report the outcome so that the view can show a message.
Events
The editor listens for a small set of events: save, cancel and remove. Each event calls one service method and then updates the editor state. Keeping the event list short makes the screen easy to test and easy to explain.
When a screen needs a second form, create a second editor rather than growing this one. One editor per screen keeps the state and the events small enough to review.