Joda - Next Generation Beans

Project
   Home
   SourceForge
   News
   FAQs
   Licence

Joda Time
   Time home

Joda Primitives
   Primitives home

Joda Beans
   Beans home
   Problem statement
   Design overview
   Getting started
   Swing binding
   XML input/output
   XPath access
   API Javadoc

Download
   Source
   CVS

Contributing
   Feedback
   Volunteer
   Contributors

 

 

 

 

 

 

 

 

Joda Swing integration

Joda's Swing integration classes aim to ease the process of getting a Swing business forms application up and running. Examples of business forms applications are call-centre applications, such as a customer identification system or bill payment system. These often require significant numbers of GUI forms consisting of textfields, checkboxes, lists and tables. They need good immediate validation and a fully featured interface.

Swing provides the basic classes to get a business forms application running - text fields, checkboxes, radio buttons and so on. Swing also provides various mechanisms for connecting the data entered to validation logic and the domain model. However, these mechanisms can be laborious, involving many inner classes that confuse the business logic with the presentation logic.

Joda Swing

A Joda domain model bean can be bound to the swing GUI easily:

  1. Create the Swing textfield
  2. Create the Joda domain model bean
  3. Create the Joda SwingBinder
  4. Bind the textfield to the property
JTextField textField = new JTextField();
Person person = (Person) JodaFactory.create(Person.class);
SwingBinder binder = new SwingBinder();
binder.bind( textField, person.surname() );

With this code, any change to the model is reflected on the GUI and any change in the GUI is reflected in the model - no inner class in sight!

The concept is to create one SwingBinder object for a whole panel/frame. Internally, the SwingBinder has its own set of Swing models that are attached to the GUI. The aim is that Joda provides the plumbing, you concentrate on the business logic.

SwingBinder active status

SwingBinder has an active flag. This allows the whole binding between the GUI and the model to be temporarily turned off. When deactivated, the binder will set the GUI component to disabled. When reactivated, any changes to the model will be made to the GUI. This allows for changes to the model to be batched, updating the GUI in one go.

The typical use case for this is a button press on the GUI that will perform a lengthy operation. The logic in the button will deactivate the binder, then do its processing, and then reactivate the binder. This technique will ensure that the user cannot enter data while the processing is in progress. It will also ensure that the changes to the model are reflected in the GUI when the processing is complete.

The best way to see this is to run one of the example programs in the JodaSwing section.

Current status

Joda currently supports JTextField, JTextArea, JList and JCheckBox. Radio buttons are supported for the particular case of Yes/No/Unknown by the JYesNoUnknownRadioButtonPanel class. The todo list includes adding support for combo boxes, tables and dates. Also on the todo list is support for a 'buffer' area between the GUI and the model to support validation can cancel button management. Developers are sought to help complete the Swing integration.