Use Data Module Wizard

Data modules simplify data access development in your applications. Data modules offer you a centralized design-time 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 visual containers like panels and frames.

The Use Data Module Wizard enables you to select an existing data module to add to your project. Once you specify a data module, all frames in your project have consistent access to all the Data Express items in the data module, 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.

To open the Use Data Module Wizard, choose Wizards|Use Data Module. This option is always available when a designable node is selected.

For a tutorial and discussion of data modules, see Separating database access logic and business rules from the user interface.

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 for it.

DataModule Class

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

You can choose to Create New Instance Of DataModule or Share (Static) Instance of DataModule. If you know you will be the only user of this data module, select Create New Instance Of DataModule.

Share (Static) Instance of DataModule

You can choose to Create New Instance Of DataModule or 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 Share (Static) Instance of Data Module.

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.

Code of the following type will be added to the jbInit() method of the Frame file when Share (Static) Instance of Data Module is checked:

employeeDataModule = untitled1.DataModule1.getDataModule();

If Create New Instance Of DataModule is checked, code of the following type will be added:

employeeDataModule = untitled1.DataModule1();