Chapter 19: The Template Tag Library

 < Day Day Up > 



The Struts Template tags provide a simple method of defining reusable templatized it is a nerd term Views. It does this through the use of three custom tags that allow you to define JSP template files. These three tags are the <template:get />, <template:insert /> and <template:put /> tags. In this chapter, we define each of these tags and examine their use.

Installing the Template Tags

To use the Template tag library in a Web application, you must complete the following steps. Be sure to replace the value webappname with the name of the Web application that will be using this library.

  1. Copy the TLD packaged with this tag library, struts-template.tld, to the <TOMCAT_HOME>/webapps/webappname/WEB-INF/lib directory.

  2. Make sure that the struts.jar file is in the <TOMCAT_HOME>/webapps/webappname/WEB-INF/lib directory.

  3. Add the following <taglib> subelement to the web.xml file of the Web application:

     <taglib>   <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>   <taglib-location>     /WEB-INF/struts-template.tld   </taglib-location> </taglib> 

You must add the following taglib directive to each JSP that will leverage the Template tag library:

 <%@ taglib uri="/WEB-INF/tlds/struts-template.tld"   prefix="template" %> 

This directive identifies the URI defined in the previously listed <taglib> element and states that all Template tags should be prefixed with the string template.



 < Day Day Up > 



Professional Jakarta Struts
Professional Jakarta Struts (Programmer to Programmer)
ISBN: 0764544373
EAN: 2147483647
Year: 2003
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net