Dynamic menu Tag library

Table of Contents

Overview

The dynamic menu custom tag library contains tags that help manage the complexity of creating dynamic menu in web applications.

Requirements

This custom tag library requires no software other than a servlet container that supports the JavaServer Pages Specification, version 1.1 or higher.

Configuration

Follow these steps to configure your web application with this tag library:

                 
                <taglib>
                  <taglib-uri>/WEB-INF/menu.tld</taglib-uri>
                  <taglib-location>/WEB-INF/menu.tld</taglib-location>
                </taglib>

To use the tags from this library in your JSP pages, add the following directive at the top of each page:

 

<%@ taglib uri="/WEB-INF/menu.tld" prefix="menu" %>

where "menu" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.

Tag Summary

menu Tags

renderMenuFromXML

renders menu from XML

renderMenuFromDB

renders menu from database

 

Tag Reference

renderMenuFromXML

Availability: 1.0

Renders menu from XML file

Tag Body

JSP

 

 

 

 

Restrictions

 

Attributes

Name

Required

Runtime Expression Evaluation

Availability

 

id

  No

  Yes

 1.0

 

Script variable id for use with standard jsp:getProperty tag and as an attribute to other tags in this tag library.

 

xmlFilename

  Yes

  Yes

 1.0

 

Name of the XML file

 

Properties

None

Examples

Define a bundle using browser preference to determine locale.  

 

 
 
<menu:renderMenuFromXML xmlFilename="/tomcat/webapps/menu.xml"/>          

 

renders menu from menu.xml file.  

 

renderMenuFromDB

Availability: 1.0

Renders dmenu from database table.

Tag Body

JSP

 

 

 

 

Restrictions

 

Attributes

Name

Required

Runtime Expression Evaluation

Availability

 

id

  No

  Yes

 1.0

 

Script variable id for use with standard jsp:getProperty tag and as an attribute to other tags in this tag library.

 

driverName

  Yes

  Yes

 1.0

 

name of the database driver

 

driverUrl

  Yes

  Yes

 1.0

 

name of the database

 

userName

  Yes

  Yes

 1.0

 

username to the database

 

password

  No

  Yes

 1.0

 

Password to the database

 

Properties

None

Examples

Display a plain message using the default (first defined) bundle.  

 

 
 
  <menu:renderMenuFromDB driverName="oracle.jdbc.driver.OracleDriver"
                         driverUrl = "jdbc:oracle:thin:@ntdev:1521:testdb"
                         userName="test"
          &n!
 bsp;              password=" test"/>          

 

Examples

See the example application menu-examples.war for examples of the usage of the tags from this custom tag library.