Application Wizard Overview


Table of Contents

1. Introduction
2. Running the Application Wizard
3. Conclusion
4. Moving Your Application to Another Server

Chapter 1. Introduction

The Enhydra Application Wizard (appwizard) is a tool with both a command-line and a graphical user interface. The wizard creates a basic framework for an Enhydra application. The wizard lets you create and run a new "stub" application in a matter of minutes, giving your development project a jump-start. The application wizard creates a new source tree for a simple Enhydra Web application. This application serves two purposes: it is an example program so that developers can test-drive Enhydra easily, and it is a good base on which to build projects. New developers are recommended to start a project by running the Application Wizard, then add and rename files as needed

Chapter 2. Running the Application Wizard

The Application Wizard has changed significantly with the release of Enhydra 3.5. Previously, the Application Wizard was a command-line tool, started by entering newapp with a parameter for the project name. The command for starting the Application Wizard and the parameters required to run it as a command-line tool have changed. The basic framework of files and directories generated by the Application Wizard has changed as well.

To create a simple application with the Application Wizard:

  • Create a directory to contain your new application and name it anything you want.

    For example:

    mkdir myapps (UNIX)
    or
    md myapps (WINDOWS)

  • Open a shell window (UNIX) or command window (WINDOWS) and make the new directory the current directory.

    For example:

    cd myapps

  • Start the Application Wizard GUI by entering "appwizard" at the command prompt. Entering appwizard with no arguments brings up the Application Wizard GUI. The Application Wizard can generate two distinct types of Enhydra projects: a Web Application, and an Enhydra super-servlet application. Note If the Application Wizard does not start, the path environment variable is not set correctly. The Enhydra installation instructions provide information about setting your path environment variable. For installation instructions refer to the top-level index.html.

  • Use the Application Wizard GUI to generate a simple Enhydra application. The Application Wizard GUI steps you through the process of generating an Enhydra project.

    • Select a a Component type

      Select Enhydra Application from the Component type pull-down menu and click Next.

    • Specify Client type and directory details.

      Accept the default client type of HTML. Enter simpleApp for the Project directory name. Enter simpleapp (note the difference in case) for Package. Set the Root path to

      /enhydra/myapps

    • Specify the copyright material to use.

      Click Next to accept the default, No copyright setting

    • Specify which Supplemental files to generate.

      Select Generate start script and command line build files and click Finish. The Application Wizard creates a new directory called simpleApp. This directory is sometimes referred to as the application root directory.

  • Make the application root directory the active directory.

    For example:

    cd simpleApp 

  • Browse the application root directory and note the following items created by the Application Wizard:

    • file build.xml

    • A readme.html file that contains some simple instructions to build and run the application

    • A source directory src, containing all the source code for the application

    • An input directory input, containing templates of the configuration files and run scripts for the application.

To build the application:

  • In the shell window (UNIX) or in the command window (WINDOWS), enter the ant command from the application root directory:

    cd /enhydra/myapps/simpleApp
    ant
    This creates two subdirectories in the application root directory:

    • classes directory contains the application's class files

    • output directory contains everything needed to run the application

    File build.xml contains directives that tell ant to recursively descend the application directory tree. When you build the application ant compiles the files located in the simpleApp source directory (simpleApp/src) and creates a corresponding directory structure in the classes directory. It then combines those classes into a JAR (Java archive) file and places the JAR file into the output/archive directory, along with the configuration files needed to run the application.

  • To start the application, enter the following commands in the Enhydra shell (UNIX) or in the command window (WINDOWS).

    • UNIX:

      cd output
      ./run 

    • WINDOWS:

      cd output
      run 

    Note: The Multiserver Administration Console provides a GUI for managing applications. Among other functions, the Admin Console can be used to start and stop applications.

  • To access the application, enter the following URL in your browser's location field:

    http://localhost:8002 

The browser will display the Welcome page for the simpleApp application.

You should see "Welcome to simpleApp..." and the current date and time. Hit the reload button and watch the time update. The time is a sample of dynamic HTML: it could be replaced with anything you can access or compute in Java.

Clicking on the link "Sample redirect back to here" sends the browser to a special page that always responds with a redirect request back to the main page. Sometimes this occurs so quickly you may not notice anything happening. Redirects are very useful when you are building a Web application.

Chapter 3. Conclusion

Congratulations! You have just created a Web application using Enhydra! We recommend you take some time to examine the build.xml files, the Java code, and the html files. Familiarizing yourself with a simple clear-cut example will make it much easier to understand the source code to the two demo applications DemoCart and DemoApp. They are good examples of advanced uses of the Enhydra Application Framework.

Chapter 4. Moving Your Application to Another Server

If you want to try your application in another server, go to the top of the tree and type "ant".

Your application is a servlet, so the server will need to support servlets. In Apache, for example, you should add the JServ servlet runner module. Add a servlet to your server (see the documentation for your server for instructions on how to do this). You will need to supply the following three pieces of information:

  • Classpath:

    <name>.jar and jar files from lib directory of your Enhydra installation 

  • Class name:

    org.enhydra.Servlet  

  • Initial parameter:

    "confFile=/......./<name>.conf" 
    (replace with the full path to the config file for your application, in the output directory).

Adding a servlet is very server-specific, please see your server's documentation.