Use Data Module wizard

This is a feature of JBuilder Professional and Enterprise.

To open the Use Data Module wizard, choose Wizards|Use Data Module. This option is available when a designable node is selected. Data modules must be compiled before they can be recognized by this wizard. The Use Data Module wizard displays a choice of DataModules in the current project or lets you browse elsewhere. It also lets you pick the Java variable name to use to refer to the DataModule.

Data modules simplify data access in your applications. Data modules offer you a centralized container for all your data access components. This enables you to modularize your code and separate the database access logic and business rules in your applications from the user interface logic in the application. You can also maintain control over the use of the data module by delivering only the .class files to application developers.

The Use Data Module wizard enables you to select an existing data module to add to your project. A data module is a specialized container for data access components. Once you define your DataSet components and their corresponding Column components in a data module, all frames that use the module have consistent access to the data sets and columns without requiring you to recreate them on every frame each time you need them. Data modules do not need to reside in the same directory or package as your project. They can be stored in a location for shared use among developers and applications.

For a tutorial and discussion of data modules, see "Using data modules to simplify data access" in Database Application Developer's Guide.

DataModule Class

Important:

Data modules are only seen by the Use Data Module wizard if they have been successfully compiled into class files. You can select a data module class in two ways:

Java Field Declaration

Field Name

In the Java Field Declaration box, the default field name is the name of the data module, followed by a unique number. It is the name which will be used for the member variable to generate in code. The data module will be referred to in the structure pane and in the Component tree by the name given here. Select a name that describes the data in the data module.

Create New Instance of Data Module

If you only have a single Frame subclass in your application, select this option.

Share (Static) Instance of DataModule

If you plan to reference the data module in multiple frames of your application, and want to share a single instance of the custom DataModule class, select this option.

The Application Sets The Instance By Calling setModule()

Adds a setModule() method to the class being edited. Some other programs will need to call this method in order for the data module to be useable. When using the UI Designer on such a program, an extra property, called module, appears in the Inspector so that the user may specify which data module it wants the designer to use. Select this option when you have several different data modules, for example, a data module that gets data locally and a data module that gets data remotely, and you want the rest of the application to not care.

OK

Click OK to add the data module to the package and inject the appropriate code into the current source file to create an instance of the data module.

Based on the choices shown in the dialog above, the following code will be added to the jbInit() method of the Frame file. Note that Share (Static) Instance of Data Module is selected:

dataModule12 = com.borland.samples.dx.datamodule.DataModule1.getDataModule();

If Create New Instance Of DataModule is selected, the following code will be added to the jbInit() method of the Frame file:

dataModule12 = new com.borland.samples.dx.datamodule.DataModule1();

If The Application Sets The Instance By Calling SetModule() is selected, a setModule() method is added to the class being edited.