Installation

Requirements

To start using the Tags Library, you'll need the following:

  • JDK 1.5 or higher
  • Servlets container running Servlets 2.4 and JSP 2.0 or higher
  • The JavaScript library MochiKit. It currently makes use of the development version as recommended by the MochiKit development team.
  • The Java libraries the project depends on (they are commons-lang, log4j, json-lib and xercesImpl). Check the compile dependencies at the dependencies page.

Setup

Download

The library download can be done in two different ways:

It' is also necessary downloading the JavaScript files:

Note: In order to get a better performance and loading JavaScript files faster, it is recommended compressing such files (for example with this tool).

If you compress jstags files and include them in only one file as well, remember you can not use the enable tag but load that file yourself with a script tag instead.

Tld and JavaScript references

Although most of times you will include all the tld's in your project pages header, depending on the features you request from jstags, you may prefer including only those you need.

<!-- Include this to use any of the general tags (enable). The inclusion
of this tld is recommended -->
<%@ taglib uri="http://jstags.sourceforge.net/tld/jstags.tld" prefix="jstags">

<!-- Include this to use any of the content (Ajax) tags -->
<%@ taglib uri="http://jstags.sourceforge.net/tld/jstags-ajax.tld" prefix="ajax">

<!-- Use this to use any of the effects tags -->
<%@ taglib uri="http://jstags.sourceforge.net/tld/jstags-effects.tld" prefix="effects">

<!-- Use this to include any of the forms tags -->
<%@ taglib uri="http://jstags.sourceforge.net/tld/jstags-forms.tld" prefix="forms">

MochiKit library has to be included as well.

<script type="text/javascript" src="js/mochikit/MochiKit.js" />

JSTags needs its own JavaScript code in order to work properly. This files can be included in two different ways:

  • Directly: include the script tags with the files location. It is recommended that you either compress the files and insert them or compress and join the files into one that will be included in the page.
    <!-- Include this one always -->
    <script type="text/javascript" src="js/jstags/jstags.js" />
    
    <!-- Not necessary if only using effects. Otherwise, include it -->
    <script type="text/javascript" src="js/jstags/jstags-utils.js" />
    
    <!-- Only neccessary if you include tags from the jstags-forms.tld -->
    <script type="text/javascript" src="js/jstags/jstags-forms.js" />
        
    <!-- Only neccessary if you are to include tags from the jstags-content.tld -->
    <script type="text/javascript" src="js/jstags/jstags-content.js" />
      
    <!-- Only neccessary if you are to include tags from the jstags-effects.tld -->
    <script type="text/javascript" src="js/jstags/jstags-effects.js" />      
  • By using the enable tag: there exists a tag called enable that can be used to insert all the JavaScript files that you need depending on the jstags modules you wish to use. Such a tag needs to know about the jstags JavaScript files (it is recommended that those files be compressed.
     <jstags:enable jstagsFolder="${yourJstagsFolder}" effects="true" forms="false" content="true" />

Usage

Now, the library has been correctly installed and you can start using it.

JSON

Some of the tags attributes need either a JavaScript-like Array or Object. That is, a String in the form [...] or {...}. These attribute values can be built not only by hand but also by means of third party libraries which, depending on the case, may be easier. The third party libraries that may help you are: