Previous Next Contents Index


Chapter 5 Creating and Managing Projects

This section describes the process of creating and managing projects.

This section presents the following topics:


The Development Process
The following flowchart shows the basic steps for developing a Netscape Application Server application:

This section summarizes the development process. Separate sections describe each step in more detail, along with a simple example.

  1. Start Netscape Application Builder.
  2. Create a project.
  3. Add files to the project.
  4. Edit files.
  5. Compile individual files or build the entire project.
  6. Test and debug individual files or the entire project.
  7. Deploy the project.
The remaining sections describe each step of the development process in more detail.


Creating a Project
A project is a container for related files that constitute an application. Once you define application requirements and design the application flow, you are ready to create a project. First, launch Netscape Application Builder. Then, to create a project, choose "New Project" either from the Welcome dialog box or from the File menu.

In either case, the new project wizard appears. This wizard guides you through the creation of a simple project, as shown in the following figure:

The left graphic shows the files that the new project wizard can create; the files it actually creates depends on the files you choose to create using the wizard. These files are the foundation of a project. The default files are described in the following table:

File Created
Description
Editing Required After File is Created?
index.html
Default start page for the project.
Yes
BaseServlet.java
The default super class for all of your servlets. It contains information about shared logic.
Optional; updated automatically as you use additional wizards.
AppResource.java
The session proxy file, which contains session information. For more information about appResource.java, see Creating Presentation Logic.
Optional; updated automatically as you use additional wizards.
validate.js
Implements JavaScript-based validation for form components. For more information, see Creating Presentation Layout.
No
appInfo.ntv
Contains the application-level meta data; for example, the properties of the HttpSession object, whether an NAS back-end is used, and so on.
No

The wizard also creates a project.gxm file, which contains information about the files in a project and other information used by Netscape Application Builder and NAS. This .gxm file is the file that you choose when you open an existing project. The file is not listed in the Project window because you should never need to edit it or examine its contents.


Working with Existing Projects
This section describes how to open projects and either save them or close them.

Opening a Project
Opening a project means opening its associated .gxm file. You can open a project by using the File menu to choose Open Project, by clicking the Open Project button from the standard toolbar, or by double-clicking one of the files listed in the Welcome dialog box. When you open a file from the Welcome dialog box, you also can select "Browse for more projects" to search the file system for another .gxm file.

When you search the file system, a dialog box appears as shown in the following example:

To open the Sample project, you double-click the Sample folder to list its .gxm file. After selecting this file, you can double-click on it or click Open.

Only one project can be open at a time. If you try to open a second project when a project is already open, the first project closes after prompting you to save any changed files.

Saving and Closing Projects
Saving a project means saving all files that compose a project. To save a project, pull down the File menu and choose Save All or click on the double-disk icon in the toolbar. To close a project, pull down the File menu and choose Close Project.


Adding or Removing Files
You can add files to a project in any of the following ways:

You can also remove files that are not needed in the project.

Whenever you create files in Netscape Application Builder, they are automatically added to the current project. This means the files appear in the project tree and are tracked by the .gxm file. By contrast, previously existing files do not become part of a project unless you specifically add them.

Creating Files
To create files, you can either pull down the Project menu and choose Add Files, or you can pull down the File menu and choose New and then choose Files. In either case, the New Files dialog box appears:

To create files, either double-click an icon, or select an icon and click Add. You can use the New Files dialog box to create the following individual files:

File Type
Description
Where Added to
HTML page
A static HTML file.
Project's subdirectory in the web server's document directory.
Servlet
An instance of a Java class that implements the presentation logic of an application.
Project's subdirectory in the NAS applications directory.
Java class
A generic helper class. It starts out as a blank file, with no generated code. Therefore, you can use a Java class to create Java source files from scratch.
Project's subdirectory in the NAS applications directory.
BaseServlet
A Java file that provides a place to share common application functionality such as RowSet classes or methods for a set of servlets.
Project's subdirectory in the NAS applications directory.
Data model
Specifies the database tables and relationships to be used in the application.
Project's subdirectory in the NAS applications directory.
Query
Lets you define SQL queries. A query can be called from a servlet.
Project's subdirectory in the NAS applications directory.
JavaServer Page (JSP)
An HTML file, with Sun-specified extensions, that is executed on the web or application server instead of on the client server, dynamically creating pure HTML, which is then sent to the client.
Project's subdirectory in the NAS applications directory.
AppResource
A wrapper for an HTTP session object.
Project's subdirectory in the NAS applications directory.

You can also use the following wizards to create various sets of files:

Wizard
Description
Database Forms
Lets you create master/detail forms and reports, with an optional search page. This wizard creates a static HTML page containing a data query form; query files and data models to establish interaction with a relational database; and servlets and templates to process and display the query results.
Results
Creates a servlet and a JSP to display the results of a data-source query.
Input
Creates three files: a static HTML page containing a data input form, a servlet to process the form, and a JSP to display the results. Can also produce a query if needed.
Login
Creates three files that perform the login function: a static HTML page containing a login form, a servlet to process the form, and a JSP to display results.
Session EJB
Creates a session EJB's source files, including the remote interface, home interface, enterprise bean class, and a .properties file containing metadata.
Entity EJB
Creates an entity EJB's source files, including the remote interface, home interface, enterprise bean class, and a .properties file containing metadata.

Adding Existing Files
Files that were created outside of Netscape Application Builder are not automatically tracked by a project's .gxm file (and are therefore not considered part of a project) unless you add these files explicitly using Netscape Application Builder. The files you add must exist within the NAS applications directory tree or in the web server's document directory.

To add files that were created outside of Netscape Application Builder, perform the following steps:

  1. Using your operating system, copy the files to the appropriate directory:
  2. In Netscape Application Builder, display the Add Files dialog box by pulling down the Project menu and choosing Add Files. You can also choose New then Files from the File menu and select the Existing tab.
  3. Locate and select one or more files to add to the project, as shown in the following figure.
  4. Double click to add a file or click Add.
Removing Files from a Project
When you remove a file from a project, you delete the reference to it in the .gxm file. The removed file no longer appears in the Project window. By default, removing a file from a project does not delete it from the file system.

Take care not to remove files that other files depend on. Before you remove files from a project, you may want to view the project map to check for file dependencies.

To remove a file from the project, perform the following steps:

  1. Select the file in the Project window.
  2. From the Project menu, choose Remove File. For example, to remove index.html, choose "Remove index.html". You may also right-click on the file.
  3. Select the checkbox if you want to remove the file from the file system.
  4. Click Yes to remove the file from the project.
Displaying File Dependencies
As you add files to a project, you will find it helpful to keep track of file relationships. In this way, you can ensure that the application follows the intended design.

You can use the project map to display file dependencies. To display the project map, you can right-click a specific file, and then choose View in Map. The following figure shows the project map based on right-clicking a sample file (Hello.java).

The previous map shows that the example file Hello.html depends on another file called Hello.java. This relationship is automatically created by the Results wizard, and it means specifically that the Hello.html JSP file can be populated with data generated by Hello.java.

Next you need to define the specifics of this file dependency, and you do this by editing files, as described in the next section.


Editing Files
After you add files to a project, you edit them to fill in the details. You can edit the following types of files within the Netscape Application Builder environment:

You can optionally specify external editors for HTML and Java files. In addition, you can edit image files by designating a third-party image editor to do so. For information on setting external editors, see Setting Netscape Application Builder Options.

You can open a file for editing in any of the following ways:

The type of file you open determines which editor window appears. When a file is open, you can perform standard editing tasks such as copying, pasting, or searching for text. You execute these tasks using either the Edit menu or the standard toolbar.

Saving, Closing, and Renaming Files
When a file is open, you can save, close, or rename the file.

If a file has unsaved changes, its name appears in the Project window with boldface type and with an asterisk (*) appended to the name. Saving a file restores the name to its normal appearance in the Project window.

You can save an individual file or save all files in a project. To do so, choose Save or Save All, using either the File menu or the standard toolbar.

To close a file, use the File menu or click the Close button in the editor window. If there are unsaved changes, you are given the option of saving the file first.

To rename a file, choose Save As from the File menu, and enter the new file name.

Caution
If other files point to the file you want to rename, you might break the file dependencies within the project. It is recommended that you view the project map before renaming files.


Viewing and Editing Project File Properties
This section describes viewing and editing project file properties. Properties determine the appearance and behavior of objects in a project.

Each object in a project, including HTML and Java files as well as components and structural objects in those files, has a set of properties associated with it. Each property consists of a name, a description, and a value. The value of a property is usually an editable variable that affects the appearance or behavior of the object to which the property belongs.

The following topics are described in this section:

Viewing Properties
View and edit properties by using the Properties window.

The object whose properties are being displayed appears in the top drop-down box. Property names appear in the left column, and their corresponding values appear in the right column. When a property is selected, its description appears in the description box at the bottom of the window.

Some properties have special features to help you edit their values. For more information, see Editing Properties.

Click the alphabetical view button to view properties in alphabetical order. Click the category view button to view properties in order by category.

The Properties window has two tabs: the Properties tab shows an object's properties; the Events tab shows the browser events to which an object can respond. For more information, see Handling Browser Events.

The Properties window appears by default when you start Netscape Application Builder for the first time. To launch the Properties window if it is not in view, you can right-click an object and choose Properties, pull down the View menu and choose Properties, or press F4.

The following illustration shows the Properties window in category view:

You can view the properties of any object in your project.

Editing Properties
The values of many properties are plain text, and can be edited according to the property's constraints by clicking in the property definition and typing an appropriate entry.

For properties that must contain one of a restricted set of values, the set of possible values is represented as a drop-down box . To choose an option, click the down-arrow and select one of the listed options.

Some properties can be edited with a custom property editor, a dialog box created for a specific property. These properties show a button in the property definition box when you edit the definition. This button launches a custom property editor for that property, which helps you specify various attributes for this property value. For example, click the custom property editor button for the DataSet property on a Tile component would help you set the and format for that property. For more information on custom property editors, see Using Custom Property Editors.

Some properties, notably categories, are expandable by clicking .

For more information on RowSets and template population, see Binding JavaServer Page Components to Dynamic Data.

Using Custom Property Editors
Custom property editors are specialized dialog boxes that help you provide correct information to complex properties. Custom property editors exist which can help you with the following tasks:

Editing Data-Bound Properties
There are three standard data-bound properties that together make up a data-bound object, linking a single column of data to a component. These properties are: a RowSet, which identifies the source of the data (for example, a query); a RowField, which identifies the specific column to display (for example, a field in a query); and, optionally, a Display Format, which determines a format for the data if needed.

A data expression is one or more combinations of a RowSet with a data field, optionally with a display format and/or static characters. You can use a custom data expression to provide multiple combinations of RowSet, RowField, and Display Format inside one component.

For more information on these properties, see Binding JavaServer Page Components to Dynamic Data.

Editing Formats

A display format allows you to format dates or numerical data at run time. This feature is also called a format mask, as it masks the raw data with a different format for viewing.

To use a custom property editor to edit the Display Format property, click the custom property editor button in the property definition. The custom property editor, shown below, appears:

Choose one of the following options. When you select a format from the drop-down list, the format string and an example showing runtime appearance appear below. For more information on formatting, see Formatting Data in a Cell Tag.

Option
Usage
None
No display format applied. This is the default.
Numeric
Indicates that the value is numeric. In general, # indicates a digit if necessary (no leading zeros) and 0 indicates a digit absolutely (zero-fill if necessary). Most other punctuation is printed as shown. For example, the data 12345.6 formatted with $###,###.00 yields $12,345.60.
Date
Indicates that the value is a date. In general, D indicates a value for the day, M for month, Y for year, h for hour, m for minute, and s for second. Punctuation appears as shown, if needed. The more times the indicator is repeated, the more complex the format (DD yields 04 for the day, while DDDD yields Friday).
Custom
Custom format. Select from the drop-down list, or develop your own.

Editing Complex Data Expressions

A RowSet/RowField combination, described in Specifying or Creating a RowSet, yields one column of data from a query. You can provide more than one column of data in a given data-binding, however, by using a custom-built data expression that states which RowSets and RowFields appear in the single display.

To use a custom property editor to create a complex data expression, click the custom property editor button in the data expression property definition. The custom property editor, shown below, appears:

In general, follow these steps for each RowSet/RowField combination you need in your expression:

  1. Choose a RowSet and a RowField.
  2. Choose a format mask, if needed.
  3. Click Add.
  4. Add any text or HTML markup, such as punctuation or spacing, between fields.
  5. When you have added all the GX tags you require, click OK to insert the data expression into your JavaServer Page.
Editing URLs
There are two types of URLs for developing Netscape applications:

For both link and image URLs, the URL can be relative (local server) or absolute (local or remote server). The URL can be determined dynamically if the component that requires it is in a JSP.

Custom property editors exist for both types of URLs, as described in the following sections.

Editing Link URLs

A link URL is a target for a hypertext link. The target can be an HTML page, a servlet, or any other web object accessible from the user's browser.

  1. To specify a link URL, click the custom property editor icon. The following illustration shows the resulting dialog box, with some sample data:

  1. You can specify an object in your project by selecting an HTML page or a servlet from the drop-down boxes, or you can enter a URL by hand in the URL text box.
  2. To add arguments (name/value pairs linked with = and separated by &), click Add and specify a name and value.
  3. If this link is in an HTML template, you can bind any part of the URL to dynamic data from a servlet by clicking the associated Data-Bind button. Create a data-binding expression using the resulting dialog box as described in Editing Complex Data Expressions.
Editing Image URLs

The source code for an image on an HTML page or template is located by a URL. The URL can be relative to the page, or a fixed, absolute address. If the URL is in a JSP, it cannot be relative to the page; it must be either absolute or relative to the application root. If the image resides on a JSP, the source can be determined dynamically by a data binding.

  1. To edit an image URL, click the custom property editor for the Image Source or Low Res. Source property. The following dialog box appears:

  1. To insert a relative URL to an image in your project, choose an image from the drop-down box.
  2. To insert an absolute URL, click the Absolute URL radio button and enter the URL.
  3. If this image is in an HTML template, you can determine the URL with dynamic data from a servlet by clicking the Data-Bound URL radio button and then clicking the associated Data-Bind button. Create a data-binding expression using the resulting dialog box as described in Editing Complex Data Expressions.
Editing List Items
Form list components, such as Drop-Down List, List Box, and Radio Button Group, are often populated by dynamic data in templates. On static pages or in templates where the list options are not dynamically generated, you can edit lists that are not data-bound by selecting the List Items property and clicking the custom property editor icon.

The following dialog box helps you create list items:

Set up list items by creating name/value pairs. If you want an item to be selected by default at runtime, click the Selected checkbox for that option. To add or delete an item, click the appropriate button on the right. When you are finished editing list items, click OK, or click Cancel to abandon changes.

Note. The Drop-Down List component creates a drop-down list with an HTML select statement with the attribute size=1. This implies that only one option can be selected at a time. If you check the Selected checkbox for more than one option, behavior at runtime is undetermined. In Netscape Navigator 4.x, the drop-down box becomes a scrolling list one item high.

Similarly, to enable multiple values to be initially selected in the List Box component, you must ensure that the Multiple property is set to true.

Editing Colors
Some properties indicate a color, which must be specified using either RGB (a hexadecimal number representing a combination of red, green, and blue) or HSV (a number representing hue, saturation, and value).

You can edit color properties by specifying either HSV or RGB values. The custom color editor helps you choose colors using either method. Click the tab corresponding with the method you prefer. When specify a color in one mode, the other mode is updated. In both tabs, the selected color is shown in the rectangle on the bottom right.

The following two illustrations show the color property editor in HSV and RGB modes:


Building a Project
The Build menu includes commands for compiling Java files. Shortcuts to these commands appear on the build toolbar. Building a project is comparable to using a make utility to compile a set of source files. If building generates errors, check the Messages window to determine which file or files require editing.

Your personal preference determines how often you decide to compile code. For example, with complex code, you might compile one source file every time you make a small change to it. By contrast, you might decide to wait until there are several Java files in the project, then compile all of them using the Build Project command.

Furthermore, you can choose to skip the build commands altogether and proceed to the testing phase, because building happens implicitly whenever you test a file or project.

For more information, see Compiling, Testing, and Debugging Applications.


Deploying the Project
When a project is complete, and it runs as expected on the test server, you are ready to deploy it as an application. Deploying the project means copying the files to a live server and registering them with the server. In other words, the application becomes available to end users.

You can deploy all files to the same server, but you have the option of using more than one server. For example, you might send HTML and image files to an HTTP server but send the .gxm file and Java files to Netscape Application Server. You might also deploy the entire application to multiple servers, for scaling or redundancy.

For more information on deploying or downloading applications, For more information, see Deploying and Downloading Applications.


Testing and Debugging
You can test an individual file or an entire project. Testing an individual file lets you preview it in a web browser. Similarly, testing a project lets you preview its behavior. In this case, the browser displays the project's start page.

When you test a file or a project, Netscape Application Builder first saves and compiles files as needed. If compilation fails, you must edit the affected files, then build or test again. Once the build succeeds, the application server starts, and the test page appears in the browser.

At this point, you can test the file or project for intended behavior. For example, you can click links, click buttons, and enter data into text fields to see whether the project produces the desired results.

If the application does not work as intended, you may need to edit one or more files, or you may need to debug the project to isolate the problem.

For more information, see Compiling, Testing, and Debugging Applications.

 

© Copyright 1999 Netscape Communications Corp.