Using Kelp with an IDE


Table of Contents

1. Kelp
Kelp features
2. Project development overview
Generating or importing source files
Setting project properties
Compiling projects
Building and deploying archive files
Debugging projects
3. Kelp topics
4. Kelp sample projects
The sample servlets
5. Kelp for JBuilder - differences
Enhydra Import Wizard
6. Kelp diferences

Chapter 1. Kelp

Table of Contents

Kelp features

This document describes how to use Kelp to develop applications with XMLC for use with Enhydra 5.1. It assumes that you have a basic understanding of Enhydra and either Sun NetBeans for Java, Community Edition, Borland® or JBuilder.

Kelp is a set of tools that extend a Java integrated development environment (IDE) to simplify the development of applications for Enhydra 5.1

Kelp for NetBeans is a set of tools for Sun Netbeans for Java, Community Edition. For information on NetBeans for Java, visit the Sun NetBeans for Java website.

Kelp for JBuilder is a set of tools for Borland JBuilder. For information on JBuilder, visit the Borland website at: http://www.borland.com/jbuilder/.

Note: Kelp for NetBeans and Kelp for JBuilder function very similarly. For the sake of clarity, this chapter is written for one IDE, NetBeans for Java, Community Edition. Any notable differences for Kelp for JBuilder are addressed in a separate section at the end of this chapter.

Kelp features

Kelp provides the following tools and features:

  • Kelp Application Wizard

    The Kelp Application Wizard generates Web applications using either the Servlet API or the Enhydra programming model.

  • XML Compiler integration

    The Kelp XMLC tool lets you set XMLC options, select markup language files (e.g., HTML, XML) to compile, and call XMLC from within the IDE to create classes that generate web content dynamically.

  • Kelp Deployer

    The Kelp Deployer allows you to set up your project properties, copy static content to the document root, process templates, create deployable archives, and deploy the archives.

  • Enhydra Import wizard

    The Import wizard allows you to import Enhydra projects that use GNU Makefiles into your IDE. The Import Wizard is currently supported in JBuilder only.

  • DODS Generator

    Dods generator runs ant based xml files (build_dods.xml and build_java.xml) for generating sql and java files.

  • Enhydra XMLC properties

    The XMLC properties give you full control over how XMLC builds Document Object Model (DOM) classes from your HTML files.

  • Input Template property pages

    The Input Template property pages let you specify a list of strings to search and replace when you are generating files from templates.

  • Build integration

    Through property pages, you can set up JBuilder to invoke XMLC and the Kelp Deployer whenever you make or rebuild your JBuilder project. This feature lets you quickly ensure that your files are updated without having to run the tools individually.

    Note: Build integration is not currently supported by Kelp in NetBeans. To build Enhydra projects with Kelp in NetBeans, you must invoke the Kelp XMLC tool before building the project, and the Kelp Deployer afterwards.

  • Kelp sample projects

    These projects demonstrate techniques for creating dynamic Web pages with XMLC Web applications.

Chapter 2. Project development overview

This section outlines how Kelp can be used with an IDE to speed the development process. Using the Kelp tools and wizards together with those of the IDE, you can perform the following basic functions:

Generating or importing source files

Within NetBeans or JBuilder you can generate a new Web Application or Enhydra Application (super-servlet style application), using the Kelp Application Wizard. The generated framework of files and directories provide a useful starting point for developing applications and services for Enhydra 5.1.

If you have an Enhydra application, you can import the application into the IDE using the Enhydra Import Wizard. The Import Wizard sets XMLC properties from the settings in the makefiles. This saves you time and trouble by automating tasks such as setting up the mapping tables to customize generated class names.

Setting project properties

The Kelp project properties consist primarily of XMLC and deployment options. XMLC options can be used to set the name for a generated class file, save the generated Java source-code files, and more. The XMLC options can be specified for a file, a folder, or the project. Project settings will be overridden by folder settings, and folder settings will be overridden by file settings.

Deployment properties specify what files to include in the deployable archive file and how to deploy the archive file.

Compiling projects

Once you have generated or added the source files to your project, you can compile the project to generate the necessary classes. If you are using XMLC in your project, you must run the Kelp XMLC tool before compiling the rest of your source files.

Note: Projects compiled or built from within the IDE do not use Ant. If you want to take advantage of some of the advanced Ant capabilities, such as the DODS tasks for automatically generating entity beans, you may want to forget building your project within the IDE.

Building and deploying archive files

After you have compiled your project you can use the Kelp Deployer to create and deploy an archive file. The Kelp Deployer only deploys to mapped drives.

Debugging projects

if you are having trouble running your application, you can use the debugging capabilities of the IDE to isolate the problem. NetBeans for Java supports remote debugging. JBuilder supports debugging for applications running within the IDE. Although the debugging capabilities of the supported IDEs differ, both methods are useful. For additional information refer to "Debugging Kelp projects" ( html , pdf ).

Chapter 3. Kelp topics

  • Using the wizards and tools ( html , pdf )

  • Setting properties ( html , pdf )

  • Debugging Kelp projects ( html , pdf )

Chapter 4. Kelp sample projects

Table of Contents

The sample servlets

Kelp includes two sample projects that demonstrate how to use XMLC and Enhydra to create Web and wireless applications within JBuilder. If you are new to both Enhydra and Kelp, you can start learning Enhydra by running the Kelp sample application. The Kelp sample demonstrates only a small part of Enhydra's capabilities.

The sample servlets

The sample project consists of four presentation objects that show some of the common uses of XMLC. The sample is simplified in that it only contains a presentation layer. Production Web applications normally contain at least three packages, including presentation, business, and data. For a detailed explanation on how you can separate applications into these three functional areas, see Getting Started with Enhydra.

Note: If you have moved a sample project after running the Kelp Deployer, run the Kelp Deployer again before using the sample.

Each servlet dynamically generates HTML files using XMLC. The HTML source files are located in a resources directory. Each HTML file is compiled into a class file using XMLC. There is a corresponding Java file that implements HttpServlet for each HTML file. These files work with the generated HTML classes to create and process input from the Web pages. The Java files are located in the kelp.webapp.presentation package. The four servlets demonstrate the following:

  • Greetings Servlet: This is similar to a traditional Hello World example. This servlet contains one HTML element that is set through XMLC to greeting the user with a phrase contained in the Java source.

  • Table Servlet: One of the most common tasks in dynamic HTML generation is populating an HTML table. This servlet shows you how to define a table as a template in HTML and then populate it through Java when a user requests the page. In a real-world application, the data would most likely come from a JDBC data source. For the sake of simplicity, this example populates the table with an array of values that are hard coded into a Java file.

  • New Node Servlet: XMLC allows you to insert HTML blocks from external sources into an existing page. This example shows a page containing a span of HTML that is read in from a text file. You can modify the text file to alter the page without recompiling the HTML or Java files.

  • Form Servlet: You can use XMLC with HTML input fields to create data entry forms. This servlet shows you how to update a file on the server with input values retrieved from a Web browser. For simplicity, this example uses a property file to store displayed values. Normally, values are stored in a JDBC data source that is accessed through the business and data layers of an application.

Chapter 5. Kelp for JBuilder - differences

Table of Contents

Enhydra Import Wizard

The primary functions of Kelp are the same regardless of the IDE used. However, there are some differences in how Kelp items are accessed from within JBuilder.

Enhydra Import Wizard

The Enhydra Import wizard lets you quickly import source files from an existing Enhydra GNU Makefile project into a NetBeans or JBuilder project, capturing any XMLC options specified in the Makefile system.

Note: Applications generated by the Kelp Application Wizard from within the IDE do not use the Makefile system or Ant. Applications generated using the Kelp Application Wizard launched from the command line include a build.xml and are built with Ant.

Chapter 6. Kelp diferences

New Kelp for JBuilder 8, JBuilder 9, Eclipse 2.0, Eclipse 2.1 and JDeveloper 9 is now ant based. To use project made in old Kelp you need to open new project (in new Kelp) and to manually move sources and resources from old Kelp project to new one.

Kelp for other IDE's (and versions of IDE's) are compatible with old one and can be used instantly, only needed action is to set class paths properly, because of change in file structure of Enhydra Server 5.1 (see Enhydra 5.1 documentation).