Novell is now a part of Micro Focus

Generic Design of iManager Plugin - Part 2

Novell Cool Solutions: Feature
By R Sathish

Digg This - Slashdot This

Posted: 18 Jan 2005

This article describes the procedure to auto-generate Java classes and JSP files for an iManager plugin.

The Generator tools are hosted as Open Source project in Novell Forge, using ANTLR based StringTemplates extensively.

The Generator tools provide a RAD mode of applying Generic design.

Step 1 - Describe the prototype

Do the OOAD and find out the required pages, flow and actions.

For example, a simple "Delete Container" module will have these pages:

Page 1 - Select the container
Actions in Page 1 - Next , Cancel
Page 2 - Confirm deletion
Actions in Page 2 - Back, Next, Cancel
Page 3 - Progress page
Actions in Page 3 - Cancel

This is specified in Java properties file format as:

All elements in the Prelim section are mandatory.

TEMPLATE_PATH_PREFIX is the path of string template (.st) files. This will be the root location where you unzipped the tool.

OUTPUT_PATH_PREFIX is the path where you want to have generated Java files. You will specify the root for output package structure here.

Step 2 - Write skeleton JSPs

Refer to the JSP Mapper properties file for the macro bindings; you can edit them too.

Write the JSP template using shortcuts from these macro bindings. For example, a JSPT (JSP Template file) having a OS to select containers for deletions will be like:

A JSPT file can have 3 things:

  1. Any macro keyword without arguments, ex: WH, TF, OS
  2. Any well expanded macro with optional arguments, ex: TF("tf1"), TF("tf2","34")
  3. Any text which does not have macros, ex: "This line is text"

You can easily infer the syntax of a JSPT file. You can use any keyword like WH,TF defined in file. There are two types of macros: macros which take expandable optional arguments and macros which do static text replacement.

OS - Static text replacement for generating "iman:os control="osText" typeFilter="User" multiSelect="false"/>"
TF("tf1","20") - Dynamic macro for generating "<input type="text" name="tf1" size="20">"

Step 3 - Generate Java classes

After creating the properties file for the Plugin Page flow you can execute the command line utility to generate all Handler classes.

Execute "com.novell.admin.generic.HandlerGenerator" with the properties file as argument.

For this example you will get these files:

You need to have the files in com.novell.admin.generic package to use this tool.

Step 4 - Generate JSP files

Once you make the JSPT files, you are ready to generate them. You can generate JSP files before Java files too. Execute "com.novell.admin.generic.JSPGenerator" with the JSPT file as argument 1 and the output JSP file as argument 2.

The JSP file you will be getting will be well formed to work as an iManager JSP file. It will have necessary directives, footer and header.

Your definitions in JSPT will be inserted inside this template substituting $BODY$.

Step 5 - Integrate all files into a plugin

You should integrate the jsps and java files generated in these tools, with the Generic build.xml described in earlier articles to build a plugin.

All the required files are in

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© Copyright Micro Focus or one of its affiliates