Navigator

Navigator

Navigator is a high-function presentation layer controller that that bridges the gap between UI component binding packages and domain layer persistence packages. Just as the UI binding binds screen fields to the presentation model, Navigator works to bind the presentation model to the persistence layer.

Navigator provides a rich control model that cleanly separates UI command and navigation actions from persistence control functions.

In simple terms, Navigator operates as a light-weight event hub to monitor state and mediate the transfer of bean-encapsulated data between the UI-binding data model and the persistence layer.

Features

  • client or server-side
  • SWT or Swing
  • flexible display form styles supported, including master/detail
  • JGoodies Binding and Validation or other UI binding package
  • Hibernate, JSR-220-ORM, Apache JDO, Apache XMLBeans integration
  • flexible, event driven business logic integration
  • single presentation-side API
  • complete separation-of-concerns between domain objects and navigation operations

Screen Shot

Navigator demo app screenshot

In this example, toolbar functions are:

  • startQuery, executeQuery, undoEdit
  • firstRecord, pageBack, previous, next, pageForward, lastRecord
  • insertNew, save, saveAll, delete

Development State

  1. provide an implementation of the IDataManager interface specific to the persistence package requirements as nessary to return Collections of Person objects in response to a query. See the IDataManager JavaDoc page for further details.
  2. implement a UI PresentationModel as is standard for the binding package.
  3. wire up the general purpose ToolBar and StatusBar beans provided in the Navigator package or roll your own.

Use

Package API:

JavaDoc

Presentation-Side Interface:

Navigator presents a single API for handling UI persistence commands and navigation requests. Simple to quite complex user UI interaction modes are supported, including in particular, QBE.

Navigator models the current data set as a Collection of records of type Object. An active cursor is navigated over the data set. Both the full Collection and current cursor referenced record Object are available through the Navigator API for binding. Any standard UI Binding package, such as JGoodies Binding, can be used.

Navigator provides a clean, event-driven connection to business layer logic. Before and After events are fired by Navigator to bracket execution of all UI command and navigation operations.

Domain-Side Interface:

Persistence commands and data are processed through a DataManager adapter that connects Navigator to the provided persistence manager package. Any standard persistence package can be used, including Hibernate, JDO, EJB, JDBC, and XMLBeans. The minimum required functions of the adapter are defined by an IDataManager interface. The required functions are a concise set of query, insert, save, and delete operations, easily implemented.

Quickstart:


// Exemplary Navigator setup; presumes
// -- use of a Collection of Person objects 
// -- use of the JGoodies Binding 

// in a suitable initialization method of a JFrame class 
... {
    // build the UI
    this.setSize(620, 220);
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setContentPane(getJContentPane());
    this.setTitle("Nav/Person Demo");

    // create the Navigator controller
    nav = new Navigator(new PersonDataManager());
    nav.addNavigateEventListener(this);

    // connect up the (optional) toolbar and statusbar widgets
    getNavToolBar().setNavigator(nav);
    getNavStatusBar().setNavigator(nav);

    // build the presentation model and link it to the Navigator
    Person uiBindingObject = (Person) nav.getUIObjectAtCursor();
    presModel = new PersonPresentationModel(nav, uiBindingObject);

    // bind UI fields to the uiBindingObject fields
    Bindings.bind(firstNameField, presModel.getModel(Person.FIRSTNAME));
    Bindings.bind(lastNameField, presModel.getModel(Person.LASTNAME));
    Bindings.bind(cityField, presModel.getModel(Person.CITY));
    Bindings.bind(stateField, presModel.getModel(Person.STATE));
}

...

// and listen for navigation events to change the UI bound object 
public void onAfterNavigate(NavigateEvent e) throws Exception {
    // (re)bind the UI to the active cursor record
    presModel.setBean(nav.getUIObjectAtCursor());
}

Installation & Requirements

  • Requires JDK1.5.
  • A complete, working Persistence Manager package and Database
    • Hibernate 3.1; or
    • Apache JDO2/JPOX 1.1.0-beta4.

Subpages

Sections