Using the Nested Tag Library

 < Day Day Up > 



To use the Nested Tag Library in a Struts application, you need to include the following snippet in your Web Archive (.war) deployment descriptor, web.xml:

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

Recall from the overview of the web.xml file in Chapter 2 that <taglib-uri> is used to declare the URI (or alias) that will be referenced in each of your JSPs with a taglib directive. The <taglib-location> tag declares the actual location of the Tag Library Descriptor (.tld) file in your Web Archive.

The following snippet illustrates how your JSPs will declare their use of the Nested Tag Library with a JSP taglib directive:

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

Notice that the uri attribute specified here is the same as that declared with the <taglib-uri> tag in the web.xml file. Also, notice that the prefix attribute is set to “nested”. This attribute can be set to whatever you want; however, “nested” is the accepted default for the Nested Tag Library. The prefix attribute declares the prefix that each tag must have when it is used in the JSP, as shown here:

<nested:nest property="results">

Because “nested” was defined as the prefix, the nest tag was used as shown. However, if you choose to use a prefix of “strutsnest”, the tag would be used as follows:

<strutsnest:nest property="results">



 < Day Day Up > 



Struts. The Complete Reference
Struts: The Complete Reference, 2nd Edition
ISBN: 0072263865
EAN: 2147483647
Year: 2003
Pages: 134
Authors: James Holmes

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