Previous Contents Index DocHome Next |
Application Builder 6.0 iPlanet Application Builder User's Guide |
Chapter 8 Using Wizards to Generate Project Files
This chapter describes the iPlanet Application Builder code generation wizards that help you perform common tasks associated with building an iPlanet application.The wizards provide a quick method for automatically generating and linking together files needed for advanced application features. The following topics are described in this chapter:
About iAB Wizards
About iAB Wizards
iPlanet Application Builder provides easy-to-use code generation wizards to create sets of HTML and JavaServer pages, servlets, and database queries. To use these wizards most effectively, it is best to think of your application in terms of activities, and from there, map each activity to the use of one or more Wizards.The tasks common to most applications involve interactions between application users and the Servlets and JSPs that make up the application's business logic. iPlanet Application Builder provides two generic wizards to help you create the files necessary for gathering input from a user (the Input wizard) and giving information to the user by way of an HTML template (the Results wizards). There is also one wizard for generating input forms and output reports from a relational database (the Database Forms wizard), and one for implementing a login page with optional password validation (the Login wizard).
Wizards are invoked from the New File(s) dialog box. The following table describes the available wizards, shows their icons, and describes the types of files generated by each wizard (note that you can choose from existing files rather than generate new ones):
In all of these wizards, click Next to move on to the next step, or click Back to return to a previous step.
Using the Data Model Wizard
The data model wizard allows you to specify the database tables and relationships between them. You must create a data model before you can create a query or form. The following files are generated, with filenames based on the name you specify:
Table 8-2 Data Model Wizard Generated Files
To launch the Data Model wizard, select New File(s) from the Project menu. Select Data Model and click Add. The Insert Tables dialog appears, which allows you to use an existing connection or create a new one. Previously established connections are defined as a *.xml file in iAS's Connections folder. If you create a new connection, you must specify the driver, data source, username, password, and, optionally, a database name, for your connection.
After choosing or creating the connection, the Add Tables dialog appears, allowing you to specify the tables you want to include in your data model. Once the tables have been identified, you complete the data model by defining relationships between fields in the tables. iPlanet Application Builder displays a visual representation of the tables from which you select a field from one table and drag it to its related field in another table. By default, each relationship you create is one-to-many from the dragged field to the destination field. You can change the kind of relationship by selecting the line between the fields and modifying the Relationship property in the Properties editor.
When you finish defining relationships and close the window, iPlanet Application Builder prompts you for the file name in which to save your data model.
Using the Input Wizard
The Input wizard creates a generic input form and a servlet to handle the input. The following files are generated, with filenames based on the name you specify:
Table 8-3 Input Wizard Generated Files
The generated HTML form consists of a basic form structure containing the input parameters you specify in the wizard. The form's SUBMIT button submits the form to the generated servlet, which processes the input and merges results with the generated JSP.
To launch the Input wizard, select New File(s) from the Project menu.
Enter a base filename and location for the generated files.
- The Specify Page Name and Location dialog box appears.
Choose how you would like to process the input information, depending on how the input parameters are processed.
- You can choose Handle Information with Custom Code or Store to a Database Table, described in the following sections.
Handle Information with Custom Code
If you choose to handle the input with custom code, the wizard prompts you for the input values that you want to make available to your servlet. Choosing to use custom code causes the wizard not to generate a query file.
Store to a Database Table
To enable the input to be inserted directly into a database using a new INSERT query, choose "Store to a database table" and click Next.Perform the following steps to store the input to a database:
First, select a data model on the Specify Data Model dialog box.
You must edit the generated JSP to display the results.
In the Specify Data Connection dialog box, choose "Use an existing connection".
- If you have not yet created a data model for this project, or if your data model is not appropriate for this input, select Create a New Data Model to exit the Input wizard and create a new data model.
In the Select Input Fields dialog box, choose a table from your data model.
- If you have already set up a database connection. Otherwise, choose "Create a new connection" and click Next. Choose a database driver, a data source, and a user name and password.
- The fields in the table appear in the left column. For each table, choose whether the field appears on the form at runtime.
Using the Results Wizard
The Results wizard creates a generic servlet that is not linked to an empty JavaServer Page (JSP). You can then create presentation logic in the JSP and transaction logic in the servlet. The following files are generated, with filenames based on the name you specify:
Table 8-4 Results Wizard Generated Files
The generated servlet is a generic stub you can use to develop a piece of your application. The results of the servlet activities merge with the generated JSP to produce an HTML page at runtime.
To launch the Results wizard, select New File(s) from the Project menu. Select Results and click Add. The Specify Servlet Name and Location dialog box appears. Enter a base filename and location for the generated files.
Specify input parameters for the servlet. If you already have an HTML input page, you can read input parameters from it automatically. Alternatively, you can enter the parameters by hand using the Specify Input dialog box, shown here:
To read parameters from an existing page, select the page from the drop-down box at the bottom of the Specify Input dialog box, or click Browse to search the filesystem for the page. To specify parameters by hand, enter the name and select the appropriate settings for other properties.
Using the Database Forms Wizard
The Database Forms wizard enables you to set up interactions with a relational database and generate complex reports. The following files are generated, with filenames based on the name you specify:
Table 8-5 Database Forms Wizard Generated Files
HTML page with a data input form and optional search functionality
The generated servlet processes form for transaction (such as update, insert, delete,or search data from generated HTML files). JSP extended taglibs use the data model and query file to retrieve data from a relational database, and merges this data with the generated JSP to display the results as a static report or an editable form.
To launch the Database Forms wizard, select New File(s) from the Project menu. Select Database Forms and click Add. The Specify Servlet Name and Location dialog box appears. Enter a base filename and location for the generated files.
Choose how you would like to define the data used on your forms and reports. You can choose Use an Existing Query File, or choose Use a Data Model to create a new query file.
Use an Existing Query File
Choose a query file from the drop-down list, or browse for one. When you find the file you want to use, the Select a Query dialog box prompts you to choose a single query from the queries in the file.If you choose a select query, the Select Records Display dialog box prompts you to choose whether records should be displayed as a single record, in which only the first row of data found by the query appears in the final output, or multiple records, where all rows of data appear in the final output.
Use a Data Model
If you choose to create the details of your query from scratch, use the Select Pages to Create dialog box to choose what kind of output pages you want to produce.A master record is the primary target of a query. A detail record is the result of a secondary query, based on the master record. Combinations of master and detail queries are shown. If a set of pages can be produced, they are linked together with standard VCR-type navigation tools (first record, next record, previous record, and last record).
The types of output pages are described below:
Additionally, you can check the "Create a search page" checkbox to generate a form that enables users to search for certain records by specifying search criteria.
Specify a data model (or exit the wizard to create one). On the Specify Data Connection dialog box, choose "Use an existing connection" if you have already set up a database connection. Otherwise, choose "Create a new connection" and click Next. You are prompted to choose a database driver, a data source, and a user name and password.
Depending on the type of output you want to produce, you are prompted for display field information, first for the master query and next for the detail query. Complex pages are shown with either a master section (for single-page output) or a master page (for multiple-page output).
In each case, you must provide the following information if it is relevant to your selected output scenario:
Using the Login Wizard
The Login wizard enables you to create login functionality, optionally with password verification. The following files are generated, with filenames based on the name you specify:
Table 8-8 Login Wizard Generated Files
Optional query file to retrieve data from database if login is authenticated by database table
JavaServer Page to display the results of a successful login
To launch the Login wizard, select New File(s) from the Project menu. Select Login and click Add. The Specify Page Name and Location dialog box appears. Enter a base filename and location for the generated files.
Specify input parameters in the Specify Input dialog box. These parameters appear as text input boxes in a form on your login page. The servlet uses these parameters to verify the login. Default input parameters are Username and Password.
For each parameter, enter or choose the following information:
The Select Login Authentication dialog box prompts you to choose a method for verifying that the provided parameters constitute a valid login. The available options, Database Table, LDAP Server, and Custom, are described in the following sections.
Database Table
To authenticate your login against a database, first choose a data model, or exit the wizard and create one if needed. Create a database connection by providing a database driver, a data source, and a user name and password.On the Specify Database Login Information dialog box, choose a database table that contains login fields, and then match your input parameters with database fields.
You can save any of the fields in the table as session variables by checking the Save to Session checkbox for that field on the Specify Query Outputs to Save to Session dialog box.
LDAP Server
The Specify LDAP Server Information dialog box prompts you for information to enable a connection to the LDAP server to authenticate the login. Specify the same server name, port, organization and country as you did when you installed your directory server. Use the drop down list to choose the source of the values for the name and password.
Custom
For Custom authentication, you must provide code in the generated servlets to authenticate your users.
Using the Query Wizard
The Query wizard creates a SQL query from the tables in your data model. The following files are generated, with filenames based on the name you specify:
Table 8-10 Query Wizard Generated Files
To launch the Query wizard, select New File(s) from the Project menu. Select Query and click Add. The Specify Base Name and Location dialog box appears. Enter the name and location for the generated file. The Specify Data Model dialog appears next; you can select a data model from within the current project or browse for a data model in another project.
You are then prompted for the kind of query, which is either Select, Insert, Update, or Delete. A dialog that matches the kind of query appears. These dialogs are explained in Creating Queries.
Using the HTML Page Wizard
The HTML Page wizard creates an empty static HTML page. The following files are generated, with filenames based on the name you specify:
Table 8-11 HTML Page Wizard Generated Files
To launch the HTML Page wizard, select New File(s) from the Project menu. Select HTML Page and click Add. The Specify Base Name and Location dialog box appears. Enter the name and location for the generated file. iPlanet Application Builder creates a minimal HTML page, which sets the title and colors, in the project's HTML Pages folder and allows you to start editing the file.
Using the JSP Wizard
The JSP wizard creates an empty JSP file that is used to display dynamic data-bound HTML output. The following files are generated, with filenames based on the name you specify:
Table 8-12 JSP Wizard Generated Files
Select New File(s) from the Project menu.
Enter the name and location for the generated file.
- The Specify Base Name and Location dialog box appears.
- iPlanet Application Builder creates a minimal JavaServer page, which sets the title and colors, in the project's Java Server Pages folder and allows you to start editing the file.
Using the Servlet Wizard
The Servlet wizard creates a Java code file that you can use to define your business logic. The following files are generated, with filenames based on the name you specify:
Table 8-13 Servlet Wizard Generated Files
Select New File(s) from the Project menu.
Enter the name and location for the generated file.
- The Specify Base Name and Location dialog box appears.
If you do not wish to register the JSP, uncheck the checkbox. The default setting is to register the JSP.
- iPlanet Application Builder creates a Java code file, which defines the package, imports, class, and the class' defaultAction(), doGet(), and doPost() methods, in the project's Java folder and allows you to start editing the file.
Using the Java File Wizard
The Java File wizard creates an empty Java code file that you can use to implement non-servlet code, such as helper or utility classes. The following files are generated, with filenames based on the name you specify:
Table 8-14 Java File Wizard Generated Files
To launch the Java Class wizard:
Select New File(s) from the Project menu.
Select Java file and click Add.
- The file is given the name Blankn.java.
- You are prompted to change the name of the file when you close it after you modify the contents.
Using the Session Bean Wizard
The session bean wizard creates the Java files and an EJB Descriptors file needed to implement a session bean. The following files are generated, with filenames based on the name you specify:
Table 8-15 Session Bean Wizard Generated Files
You place methods in the enterprise bean source file to implement application-specific behavior in an EJB. The source files generated by the EJB wizard compile but have no application-specific behavior. You will have to add code to all three source files to create useful behavior; see http://java.sun.com:8081/ejb/docs.html for more information.
To launch the Session Bean wizard, select New and then Session Bean from the File menu. The Specify Base Name and Location dialog box appears. Enter the string that you want to use to construct the EJB's home name for JNDI registration as well as to create names for the iAB-generated Java files. You can change the directory if you wish. By default, it is the combination of the iAS installation directory, the relative pathname of the server's application root, and one of the following:
the EJB default package name as specified in the Java panel of the Tools menu's Development options dialog box, if a package name is specified
The package part of the directory name, which is the part after the application root, is used as the package name for iAB-generated source files. Consider the following example, in which iAS is installed a C:\iPlanet\ias6, the relative pathname for the application root is ias\Apps, the package is cdx. The bean name is CreditCheck. The generated path and file names would be as follows:the project directory if a package name is not specified in the Java panel of this dialog
Table 8-16 Session Bean Wizard Generated path and File Names
In this example, the JNDI name is java:comp/env/CreditCheck.
You can change the names of the generated files in the next dialog box. The next dialog box also allows you to specify the following bean properties and control descriptors:
Table 8-17 Bean Properties and Control Descriptors
The next dialog box allows you to specify whether the bean is stateless or stateful. If the bean is stateful, you can specify a timeout value for the bean, which is 10,000 seconds by default.
Using the Entity Bean Wizard
The entity bean wizard creates the Java files and EJB Descriptors needed to implement an entity bean. The following files are generated, with filenames based on the name you specify:
Table 8-18 Entity Bean Wizard Generated Files
The same EJB descriptor files are shared by all EJBs.
You place methods in the enterprise bean source file to implement application-specific behavior in an EJB. The source files generated by the EJB wizard compile but have no application-specific behavior. You will have to add code to all three source files to create useful behavior; see http://java.sun.com:8081/ejb/docs.html for more information.
To launch the Entity Bean wizard, select New and then Entity Bean from the File menu. The Specify Base Name and Location dialog box appears. Enter the string that you want to use to construct the EJB's home name for JNDI registration as well as to create names for the iAB-generated Java files. You can change the directory if you wish. By default, it is the combination of the iAS installation directory, the relative pathname of the server's application root, and one of the following:
the EJB default package name as specified in the Java panel of the Tools menu's Development options dialog box, if a package name is specified
the project directory if a package name is not specified in the Java panel of this dialog
The package part of the directory name, which is the part after the application root, is used as the package name for iAB-generated source files. Consider the following example, in which iAS is installed a C:\iPlanet\ias6, the relative pathname for the application root is ias\Apps, the package is cdx. The bean name is CreditCheck. The generated path and file names would be as follows:
Table 8-19 Entity Bean Wizard Generated Path and File Names
In this example, the JNDI name is java:comp/env/CreditCheck.
You can change the names of the generated files in the next dialog box. The next dialog box also allows you to specify the following bean properties and control descriptors:
Table 8-20 Bean Properties and Control Descriptors
Previous Contents Index DocHome Next
Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.
Last Updated April 28, 2000