JDAL Swing M-VC
JDAL Swing provides support for the development of the Model-View-Controller pattern in its simplified version M-VC, in which the controller and thr view is united in the same class.
In the figure on the right, you can see the hierarchy of the the View interface up to the main class info.joseluismartin.gui.AbstractView .
Model Holder
ModelHolder which defines the methods that have the types that hold domain models:
- T getModel () obtain model of ModelHolder
- void setModel (T model) actualize the value of the model in the ModelHolder
The types that implement ModelHolder are treated in a special way, in some cases, for example in the case of the CompositeBinder which automatically dereferencing ModelHolders when carry out operations relating to the models.
Binder
The Binder interface add two methos to ModelHolder for moving data between models and UI Controls.
- update(): Update the model with the values of the controls on view.
- refresh(): Update the view with the model data.
- getBindingResult() Returns a Spring BindingResult with errors from the binding operation.
View
View add to Binder the methods that should be implemented of paradigma MVC.
- getName(): Return the name assigned to the view.
- getPanel(): Return the JComponent associated with the view.
- validateView(): Perform the validation of the model values that contain the view. The validation process in the default implementation is delegated in a Spring Framework Validator, so all the validators are supported by Spring are supported in JDAL Swing, including JSR-303.
- getErrorMessage():Return a String with the results of the validation errors
- clear(): Put the values of the controls of the view in the default value by.
- isDirty() Check that the controls have been modified since the last time refresh().
- enableView() Permit the activation/disactivation of all the view controls
AbstractView
AbstractView is the principal template ( Template , GoF) of JDAL Swing. We see how to use AbstractView in the next chapter.
th_footer(); ?>