Skip to content
Model centric tools for Spring development Community portal
Skyway PerspectivesModel driven delivery

MyEclipse for Spring

Code Reference: CustomerEditWidget.java

The GWT widget that renders the customer form. This page covers the widget structure, bindings and the events it raises.

Code assistant view showing generated Java types and model annotations
Figure 25. The widget binds form fields to the editor and raises save and cancel events.

CustomerEditWidget is the GWT view for the customer form. It builds the input fields, binds them to the editor and raises events when the user acts. The widget contains no business rules and no service calls.

Structure

  • Fields. A name box, an email box and a status list.
  • Actions. Save and cancel buttons.
  • Messages. An area for validation and success messages.
  • Binding. A small adapter between the editor state and the widget fields.

Events

The widget raises a save event with the current values and a cancel event with no payload. The presenter listens for both and decides what to do. That split keeps the widget reusable and makes it testable without a browser.

UI XML. The layout lives in the matching ui.xml file. Keeping layout out of Java makes the form easier to change and easier to review.

The widget is generated. To add a field, add it to the model and regenerate both the widget and its ui.xml file. Hand written widgets can be kept in a separate package and are not overwritten.