concept driver in category gwt

appears as: drivers, driver, The driver, driver
GWT in Action

This is an excerpt from Manning's book GWT in Action.

The collaboration between these objects is as follows: the editor updates the domain object with data, and the domain object propagates data back to the editor. This cooperation is done by a driver that has two main operations called flush and edit. The framework provides two different drivers to choose from, the RequestFactoryEditorDriver and the SimpleBeanEditorDriver. You can create your own driver if you wish, but that’s a little beyond the scope of this book. We’re going to talk more about drivers later in this chapter. The flush operation is used to update the domain object from an editor (for example, store data), and the edit is used to propagate the data from a domain object to the editor (for example, display data).

Figure 9.1 depicts the major interaction between the three participating components in the Editor framework. You can see that the editor flushes user input through the driver into the domain object and that the domain object edits the editor object with its property values, once again through a driver.

Figure 9.1. Cooperation between an editor, a domain object, and a driver. The editor flushes data to the domain object, and data is copied into the editor with edit and flush operations provided by the driver.

9.5. Binding an editor with drivers

The piece of code that performs the magic behind the editing and flushing of data is the driver. Drivers are essential in the process of editing beans.

In that process the driver needs to know how to bind data. It tries to find a hint of how to relate the properties of a domain object and the editor together. That clue comes from the way you choose to declare your editor’s properties. You’ve seen that editors are nested and could present a whole object hierarchy graph, but you only have to bind the driver on the top-level editor.

The driver descends into everything that it identifies as an editable property in the editor. Every editable property, as we mentioned before, has to be of the editor type. So if the property isn’t annotated with @Ignore in the editor, the driver will try to find a corresponding property in the domain object. In the following pages you’ll see how to use our previously defined editor and domain object with both drivers. There’s a slight variation in the syntax required in order to initialize and declare the edit and flush instructions between the two drivers. Otherwise, the piece of code needed for gluing the two objects together is similar for both drivers. Here we’ll start out with the SimpleBeanEditorDriver and end with the RequestFactoryEditorDriver.