Pramati Technologies

Packaging Tags

Overview

The Package Tool helps to build an archive of taglib components. The archive consists of tag classes, other classes, and XML tag library descriptor file. The Tag Library Descriptor (TLD) file describes a tag library. A JSP container uses the a TLD to interpret pages that include taglib directives that refer to the related tag library. The TLD is also used by JSP page authoring tools that generate JSPs, and by authors who create JSPs, manually.

Creating a taglib

To create a taglib, select Tools > Package > Taglib > New.

Enter the name of the Taglib in the dialog that appears. The taglibs are saved under the specified JAR node in the desk. Click OK to create a new Taglib JAR. Edit the following details under the details section:

Storing a Taglib

There are three ways to store taglibs and using them in a JSP.

Method1

    1. Create a taglib under the WEB-INF/lib folder which is under a web module and accepts files of type JAR.
  1. Create a JSP file and give the taglib URI as WEB-INF/lib/taglib_name.jar where taglib_name is the name of the taglib created. This enables the JSP compiler to locate the taglib descriptor, taglib.tld

Method2

  1. Create a taglib in the desired location.
  2. While packaging the WAR, you need to map the taglib URI used in the JSP and the location of the Taglib JAR in the WAR. To do this, open the WAR file and click on the Taglib node. Use the Add button to add the URI and location of the taglib.
  3. The taglib URI has to be of the same value as the taglib URI directive used in the JSP.
  4. The taglib location is mentioned so that the URI describing a tag library can be mapped to a Taglib descriptor. This is usually WEB-INF/lib/taglib_name.jar where taglib_name is the name of the taglib created.

The first method is recommended, as using the given structure requires no changes to be made while packaging the WAR. To know more about the second method, read the section on Packaging Web Components.

Adding Tags

Tools > Package > Taglib Name > Right Click > Add Tag

Select the Tag to be added to the Taglib and click on OK. This adds the Tag to the Taglib and the details can subsequently be viewed in the Tag node. Selecting the Tag name displays the details on the right hand side of the window. The following details of the tag are displayed here. These details are not editable:

Add and Remove the attributes that the tag requires to be written in the taglib descriptor file. Set the following sub-elements of the attribute here:

To delete a tag that has been added to the taglib JAR, click on Delete. After adding all the tags in the taglib JAR, assemble the taglib JAR into a WAR file.

Updating Taglib

Taglib file on the Desk> Right Click > Update

This updates the taglib, static content like HTML, images and all classes. If the package names of the above are changed, then the changed components are not updated. Files like HTML, and images are stored with their absolute paths and therefore may not be located if they have been moved from their original location.

Note: These files that are stored with their absolute paths, may not be located if they have been moved from their original location.

A time stamp based update is used to update the taglibs, which makes the updating faster in most scenarios. Choosing Update brings up a dialog box with a progress bar. All the updating messages are displayed here. To stop updating the taglib, click on Cancel. Studio in the meantime can be used as usual but the taglib file being updated cannot be opened.

A log of update operations is available on the Update Tab in the Output area of Studio. This log shows normal messages in black, updating messages in green and any failures or errors in red. Usually a remedial measure is also provided in the case of errors. A progress bar indicates the progress of the operation.

Saving Taglib

Tools > Package > Taglib > Save saves the open Taglib.

Closing Taglib

Tools > Package > Taglib > Close. This command closes the current Taglib. The Taglib is saved before closing.

Reverting Taglib

Tools > Package > Taglib > Revert restores the taglib to its last saved state.

Viewing XML Files

The META-INF/taglib.tld file corresponding to the Taglib JAR can be viewed in the XML node.


Pramati Technologies  © Copyright   TOCPREVNEXTINDEX