A visual component, like a table or a text field, needs a data source from which to pull data, and potentially to push data to. The Java visual editor provides three types of helper classes that can be generated into your project to enable simple and quick binding of visual components with data from a data source. The goal of these helper classes is not to provide a runtime framework for binding data to visual components, but rather to provide a quick-start to the visual development of client applications.
The three types of helper classes are data sources, data objects, and binders, each of which are discussed in more detail below. While the visual editor generates Swing-specific binder classes for the different Swing components supported, the data source and data object classes are completely independent of the visual components, allowing for possible future support of other widget libraries.
See the API documentation for the binder classes.
To learn about using the Java visual editor binders to connect to a data source, do the following tutorial:
Tutorial: Build a rich Java client that uses a Web service.
The following list describes some of the benefits of the binder classes that are generated and instantiated by the Java visual editor when you bind visual components:
As you bind visual components to data sources and data objects, binder code is generated as needed into your project source directory. By default, the generated classes are added to a jve.generated package in your project. You then have the freedom to extend, replace, or rewrite the data binding logic. The Java visual editor provides will provide visual support for data objects, data sources, and binders that correctly implement the provided interfaces.
Figure 1. A high-level overview of how the Java visual editor binds visual components to data objects and data sources


A data source represents a data factory. It can be based on an EJB session bean, a Web service, a Java Bean factory, or anything that implements the IDataSource interface. A properly configured data source in the visual editor returns the set of available services from the actual data factory, making them available to the application.
A data source can be viewed as a factory for a facade. The data source provides configuration properties that allow the instantiation and initialization of a data source facade. The facade is a class that provides a set of methods that might create data objects from the back end or provide some other business function. During run time, the getDataSource() interface is used to get an instance of the facade. It is up to the data source implementer to ensure that the facade is instantiated properly. For example, an EJB Data Source calls the home interface to create the designated session bean before a getDataSource() is called. The getType() must return the type (Class) of the facade class. This API is called in design time, mainly for method introspection.




A Data Object wraps a Java Object to manage it and provide event change support for it. The target object is accessible via the getObject() method on the IBoundObject interface.
There are several types of data objects implemented by the Java visual editor and available in the palette:

In Figure 1, the text fields are bound to properties in a Data Source Data Object that represents a data object that is returned by a call to Service2(param). In this release, only services that take one or fewer arguments are supported by the helper classes. As a workaround, you could wrap a set of arguments in another service.


In the earlier figure, the visual table is bound to a Data Source Row Object that represents an array of data objects returned by calling Service1 on the data source. The columns in the table are mapped to fields in the Data Source Row Object.

Figure 1 shows that the Row Table Binder listens for the selected row in the visual table and provides the basic data object for that row. That basic data object is then used as a parameter for Service2(param) to return a Data Source Data Object. The text fields in Figure 1 are bound to this Data Source Data Object.
It is similar to the Row Table Binder, which gets its row data directly from a service call on a data source.
In Figure 1, Text Binders bind the visual text fields to properties in the Data Source Data Object that is returned by Service2(param). The parameter for Service2 in Figure 1 is collected from the selected row (probably a key field such as an ID) in the table. In this example, Service2 presumably returns more properties about the selected row in the visual table. For example, the visual table could list all employees, with last name and employee ID. The employee ID of the selected row is used as the parameter for Service2, which might return a full record for the employee, including the employee's salary. A text field could then be bound to the salary property in the data source data object returned by Service2.
The Java visual editor supports binding JButtons to actions. When a button is bound to an action binder, the action binder can automatically change the button's enabled state when the arguments for the action change. For example, an action binder that invokes a service call could change the enabled state of a button when the parameters for that service call change.
In Figure 1, for example, the action binder for the button uses as its parameter the same data object that the text fields are bound to. So, if the text in the text fields change, the action binder for the button detects that the data object has changed and the action binder could tell the button to become enabled. Then, if the button were clicked, the action binder would take the new data object, with the changed values in the text fields, and invoke Service3(param) on the data source.
In Figure 1, a Text Filter Binder binds a text field to a particular column in the table.
Again, it is important to note that the generated classes and interfaces are simply a quick and easy way to get you started with binding visual components to data objects and services. The binders generated by the Java visual editor are not meant to be a framework, but are rather a generic, default implementation that works properly with the Java visual editor. You can enhance and customize the classes and interfaces in the generated package to meet the particular needs of your application and data source. If you do enhance the classes, the visual editor will still provide visual support for them as long as they correctly implement the provided interfaces.