EGL can create a simple data access application based on
a database to which you are connected. The resulting application contains
data parts, logic parts and (optionally) web pages that are based
on one or more database tables.
Files created for the application
For each
table that you select, the EGL Data Access Application wizard creates
the following parts. You can choose to put these parts into a new
project or into one or more existing projects.
- Data parts based on the table:
- An SQLRecord part that represents the table
- DataItem parts that represents the columns in the table
- Data access functions that perform operations on the database,
such as adding, retrieving, and deleting records. You can choose to
put these data access functions in libraries or in services.
Also, you have the option of creating a web interface
for the data access application. If you choose to create a web interface,
the wizard creates these additional files and parts:
- A set of JSF handler parts that you later generate into a set
of parts that run under JavaServer Faces
- A set of JSP files that provide the following web pages:
- A selection condition page, which accepts selection criteria
from the user
- A list page, which displays multiple rows, based on the
user's criteria
- A create detail page, which enables the user to display
or insert one row
- A detail page, which enables the user to display, update,
or delete one row
Projects in the application
Before you begin
creating the application, make two decisions about where the new files
and parts will go:
- You can put all the new files and parts into one project, or you
can put the files and parts into different projects, based on the
kind of file and part. Data parts, logic parts, and JSF handler parts
(with the associated web pages) can all go into separate projects.
- You can put files and parts into a new project or into an existing
project. If you choose to put parts into different projects, some
can go into an existing project and others can go into a new project.
Creating the application
- Click .
- In the New window, expand EGL and click EGL
Data Access Application.
- Click Next.
- In the Project Name field, either select
an existing EGL project or type the name of a new project. Later,
you will be able to fine-tune where the new data parts, logic parts,
and web pages will go, but at least one kind of part will go into
the project you specify here.
- In the Database Connection list, select
a database connection. You can create a new one by clicking the New button.
For more information, see Creating an SQL database connection.
After
you have selected a database connection, the tables in the database
schema are listed in the Table Name list.
- In the Table Name list, select the check
box next to the tables that you want to include in the data access
application.
- If you want to create a web interface for the application, including
JSF handler parts and web pages, select the Generate to
EGL web project check box. If you clear this check box,
your application will contain logic parts and data parts that enable
you to access the database, but no JSF handler parts or web pages.
- Click Next.
The Define the Fields page
has a tab for each table that you selected on the previous page. On
this page, you select the key fields for each table and which fields
you want to be able to search.
- Select the key fields for each table in the Choose
key fields list. If the table already had a key field
in the database, that field is selected as a key already. You cannot
remove a key field that is defined in the database.
- If you are creating a web interface, select the search fields
for each table in the Choose search UI fields list.
The wizard creates a search page for each table you selected, and
that search page will have an input field for each field that you
select here.
- Click Next.
If you are creating a web
interface, you will see the Configure the Fields page. Otherwise,
the wizard skips ahead to the Define Generation options page.
As
in previous steps, the Configure the Fields page also has a tab for
each table that you selected. On this page, you select how the web
pages will display the data.
- Set the display name for each field in the Modify field
display name list. The value in the Display
As column will be that field's label wherever it appears
on a web page. In EGL terms, this value becomes the value of the displayName data
item property.
- Select the fields to show on the search results page by selecting
check boxes in the Choose summary fields list.
- Click Next.
The Define project creation
options page has options for the new projects and packages.
- In the Default package name field, type
the name of the top-level package that will contain the new EGL parts.
The default value is the name of the database connection.
- Under Data access method, select whether
you want to create library parts or service parts to hold the new
data access functions.
- If you want to prefix the names of the tables with the name of
the database schema, select Qualify table names with schema.
This check box determines whether the EGL code will refer to the database
table simply by the table name or by the schema name and the table
name.
Whether you select this check box or not depends on how you
are connecting to the database. For most testing databases, or if
you want to create a simple application as quickly as possible, you
specify the schema name in the EGL code to avoid specifying the table
name in other places; in this case, select the check box. For most
production databases, you specify only the table name in the EGL code
and specify the schema name in a bind step in the JCL; in this case,
clear the check box.
- If the names of any of the tables or columns in the database are
SQL reserved words, or if the table or column names include any characters
that are not valid in ANSI SQL, such as characters from DBCS languages,
select the Use delimited SQL identifiers check
box. If you select this check box, the EGL code will use quoted strings
for the table and column names.
- If you want to put all of the new files and parts into one project,
clear the Create multiple projects check box.
All of the new files and parts will be created in the project that
you entered in the Project Name field on a
previous page. Then, click Finish.
- If you want to put the new files and parts into different projects,
select the Create multiple projects check box
and then click Next. Specify additional options
about the projects on the next page.
The Define alternate project
locations page enables you to select separate projects to hold the
new data parts, logic parts, and web interface files and parts, with
the following restrictions:
- At least one of the projects must be the same as the project you
entered in the Project Name field on a previous
page.
- You cannot put all of the files and parts in the same project.
If you want to put all of the files in the same project, go back one
page and clear the Create multiple projects check
box.
- For each kind of file or part, choose a project.
- In the Data Project Name field, select
a project to hold the new data parts.
- In the Data Access Project Name field,
select a project to hold the new logic parts (services or libraries,
depending on your choices on the previous page).
- In the UI Project Name field, select a
project to hold the new web pages and JSF handler parts.
- For each project, select the EGL Web Project field
if you want the respective project to be an EGL web project.
- Click Next.
- The final page of the wizard shows a summary of your choices so
far. You can click Finish and complete the
process or go back to previous pages and change your selections.
- After the projects and files are created, you might need to add
the projects to the EGL and Java™ build
paths of other projects. See The EGL build path.