blob: e834d968c5bf38ed07c41ce09cfb0ac6fd4fa778 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Fri Jun 15 16:53:35 PDT 2001 -->
<TITLE>
Apache Struts API Documentation: Package org.apache.struts.taglib.template
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../org/apache/struts/taglib/logic/package-summary.html"><B>PREV PACKAGE</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/apache/struts/taglib/template/util/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html" TARGET="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="package-summary.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<H2>
Package org.apache.struts.taglib.template
</H2>
The "struts-template" tag library contains tags that are useful in creating dynamic
JSP templates for pages which share a common format.
<P>
<B>See: </B>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="#package_description"><B>Description</B></A>
<P>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Class Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="GetTag.html">GetTag</A></B></TD>
<TD>This is the tag handler for &lt;template:get&gt;, which gets
content from the request scope and either includes the content or prints
it, depending upon the value of the content's direct attribute.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="InsertTag.html">InsertTag</A></B></TD>
<TD>This is the tag handler for &lt;template:insert&gt;, which includes
a template.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD WIDTH="15%"><B><A HREF="PutTag.html">PutTag</A></B></TD>
<TD>Tag handler for &lt;template:put&gt;, which puts content into request scope.</TD>
</TR>
</TABLE>
&nbsp;
<P>
<A NAME="package_description"><!-- --></A><H2>
Package org.apache.struts.taglib.template Description
</H2>
<P>
<p>
The "struts-template" tag library contains tags that are useful in creating dynamic
JSP templates for pages which share a common format. These templates are best used
when it is likely that a layout shared by several pages in your application will
change. The functionality provided by these tags is similar to what can be
achieved using standard JSP include directive, but are dynamic rather than static.
</p>
<a name="doc.Description"></a>
<p>
<div align="center"> <a href="#doc.Introduction">[Introduction]</a> <a href="#doc.Functionality">[Template
Functionality]</a> <a href="#doc.Properties">[Template Properties]</a> <a href="#doc.Examples">[Template
Examples]</a> </div>
<p></p>
<hr />
<a name="doc.Intro"></a>
<h3>Introduction<a name="doc.Introduction"></a></h3>
<p>
The Template library supplies tags that are useful for creating dynamic JSP templates
for pages which share a common format.
</p>
<a name="doc.Functionality"></a>
<h3>Template Tag Functionality<a name="doc.Functionality"></a></h3>
<p>Each of the three template tags has a specific, interelated function:</p>
<p>
<ul>
<li><b><a href="/struts-template.html#get">get</a></b> - Retrieves content from a request scope bean, for use in the template layout.</li>
<li><b><a href="/struts-template.html#insert">insert</a></b> - Retrieves (or includes) the specified template file, and then inserts the specified content into the template's layout. By changing the layout defined in the template file, any other file that inserts the template will automatically use the new layout.</li>
<li><b><a href="/struts-template.html#put">put</a></b> - Creates a request scope bean that specifies the content to be used by the get tag. Content can be printed directly or included from a JSP or HTML file.</li>
</ul>
</p>
<h3>Template Tag Properties<a name="doc.Properties"></a></h3>
<p>The three template tags use very simple attributes :</p>
<blockquote>
<p><b>get</b> - Requires a single property, the name of the content to be inserted. This tag is used in the template file to indicate where in the layout to insert the content. This name matches the name property used by a put tag.</p>
<p><b>insert</b> - Requires a single property, the name of the template. This tag is the parent to one or more put tags. The put tags indicate the content to be inserted into the template. The layout of the content is determined by get tags placed in the template.</p>
<p><b>put</b> - Requires a name property, which should match a name used in the template file. The content property indicates the source of the content. The optional direct attribute indicates whether the content should be included or printed directly (as a literal string). The default is false, meaning content is included.</p>
<a name="doc.Examples"></a>
<h3>Template Tag Examples</h3>
<p align="center"><b>A sample template file</b></p>
<blockquote>
<hr>
<pre>
&lt;%@ taglib uri='/WEB-INF/tlds/struts-template.tld' prefix='template' %>
&lt;html>&lt;head>&lt;title>&lt;template:get name='title'/>&lt;/title>&lt;/head><br>&lt;body background='graphics/blueAndWhiteBackground.gif'>
&lt;table><br> &lt;tr valign='top'>&lt;td>&lt;template:get name='sidebar'/>&lt;/td><br> &lt;td>&lt;table><br> &lt;tr>&lt;td>&lt;template:get name='header'/>&lt;/td>&lt;/tr><br> &lt;tr>&lt;td>&lt;template:get name='content'/>&lt;/td>&lt;/tr><br> &lt;tr>&lt;td>&lt;template:get name='footer'/>&lt;/td>&lt;/tr><br> &lt;/table><br> &lt;/td><br> &lt;/tr>
&lt;/table><br>&lt;/body>&lt;/html>
&lt;%<br>/*<br>"chapterTemplate.jsp"
Display a "sidebar" in a column along the left side of the page.<br>Display a "header" over the right column.<br>Display the page "content" below the header.<br>Display a "footer" at below the content.<br>If we change the layout of the elements on this page, all pages<br>inserting this page will also change to use the new layout.<br>*/<br>%>
</pre>
<hr>
</blockquote>
<p align="center"><b>A sample JSP using the template</b></p>
<blockquote>
<hr>
<pre>
&lt;%@ taglib uri='/WEB-INF/tlds/struts-template.tld' prefix='template' %>
&lt;template:insert template='/chapterTemplate.jsp'><br> &lt;template:put name='title' content='Templates' direct='true'/><br> &lt;template:put name='header' content='/header.html' /><br> &lt;template:put name='sidebar' content='/sidebar.jsp' /><br> &lt;template:put name='content' content='/introduction.html'/><br> &lt;template:put name='footer' content='/footer.html' />
&lt;/template:insert>
&lt;%<br>/*<br>"introduction.jsp"
Specify template for this page (chapterTemplate.jsp).<br>The chapterTemplate.jsp defines the layout positions for five<br>elements: title, header, sidebar, content, and footer.<br>Specify the source file (html or jsp) for each element.<br>*/<br>%>
</pre>
<hr>
</blockquote>
<p align="center"><b>A sample HTML content file ("header.html") used by "introduction.jsp", and others.</b></p>
<blockquote>
<hr>
<pre>
&lt;table><br>&lt;tr><br>&lt;td>&lt;img src='graphics/java.gif'/>&lt;/td><br>&lt;td>&lt;img src='graphics/templates.gif'/>&lt;/td><br>&lt;/tr><br>&lt;/table>
</pre>
<hr>
</blockquote>
<p align="center"><b>A sample JSP content file ("sidebar.jsp") used by "introduction.jsp", and others.</b></p>
<blockquote>
<hr>
<pre>
&lt;font size='5'>&lt;a name="top">Topics&lt;/a>&lt;/font>&lt;p><br>&lt;table width='145'><br> &lt;tr>&lt;td>&lt;a href='introduction.jsp'><br> Introduction &lt;/a>&lt;/td>&lt;/tr><br>
&lt;tr>&lt;td>&lt;a href='using.jsp'><br> Using Templates &lt;/a>&lt;/td>&lt;/tr><br>
&lt;tr>&lt;td>&lt;a href='optional.jsp'><br> Optional Content &lt;/a>&lt;/td>&lt;/tr><br> &lt;tr>&lt;td>&lt;a href='more.jsp'><br> ... and more ...&lt;/a>&lt;/td>&lt;/tr><br> &lt;/table>&lt;/p><br>
&lt;%<br>/*<br>Specify navigational links for this application.<br>*/<br>%>
</pre>
<hr>
</blockquote>
<p align="center"><b>A sample HTML content file used by "introduction.jsp" only.</b></p>
<blockquote>
<hr>
<pre>
&lt;html><br>&lt;head><br>&lt;link rel="stylesheet" href="css/templates.css" <br>charset="ISO-8859-1" type="text/css"><br>&lt;/head><br>&lt;body>
&lt;h3 class="ChapTitle">Introduction&lt;/h3><br>&lt;p class="Paragraph">Window toolkits typically provide a layout mechanism
&lt ... />
<hr>
</pre>
</blockquote>
<!--
<h3>Optional Content</h3>
<p>All content is optional. If a source page does not specify the content for an element in the template, that element is simply ignored. This can make using templates more flexible, since you can use the same template for more than one page, simply by ommitting or specifying a content element. However, this feature also means that a misspelled name could lead the template to quietly ignore content you meant to include.</p>
-->
<P>
<HR>
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../../org/apache/struts/taglib/logic/package-summary.html"><B>PREV PACKAGE</B></A>&nbsp;
&nbsp;<A HREF="../../../../../org/apache/struts/taglib/template/util/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../index.html" TARGET="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="package-summary.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
Copyright © 2000-2001 - Apache Software Foundation
</BODY>
</HTML>