Monday, September 24, 2007

Added SimpleForm component to Verdantium Downloads

Like SimpleSax from my previous post, SimpleForm is another simple demo component. A lot of GUIs display forms with text fields and pull-down menus. A good example is a GUI that asks for name, address, phone number, social security number, etc. For a GUI like this it is very useful to separate then Model and Controller from the View in a Model-View-Controller (MVC) architecture. This component provides a simplified example of how such a separation can be implemented. In this component the view, i.e. the topPane panel in class SimpleForm, is separate from the model, the SimpleForm instance, that actually controls the behavior and the persistence. Unlike Java Beans where the component extends a GUI, a Verdantium component like SimpleForm has a GUI through aggregation. I think this is a much cleaner architecture. It makes more sense to build topPane from an external model/controller than it does to effectively "extend" topPane.

Another problem with JavaBeans is that making the bean "extend" topPane and implement Serializable tends to create a class that serializes the details of its GUI (i.e. all the text fields, labels, etc.). Verdantium intentionally puts the persistence methods in class VerdantiumComponent so that the component only serializes its data model.

Give this one a try by loading its ".xnl" file through the Discovery component.

No comments: