template:get

 < Day Day Up > 



<template:get />

The <template:get /> tag is used to retrieve the contents of a bean stored in the request scope, with the intention of replacing the tag instance with the contents of the retrieved bean. It is used to define the actual template JSP that will be referenced by the <template:insert /> tag. The bean being retrieved is assumed to have been placed on the request by a <template:put /> tag. The <template:get /> tag has no body and supports three attributes, as shown in Table 19.1.

Table 19.1: <template:get /> Tag Attributes

Attribute

Description

name

Identifies the name of the request attribute to be retrieved. The name attribute should match the name attribute of the <template:put /> tag. (Required)

role

Specifies the role in which the user must exist for this tag to be evaluated. If the user does not exist in the named role, then the tag is ignored. If no role is named, then the tag will be evaluated by default. (Optional)

flush

If set to true, results in the flushing of the response buffer prior to the inclusion of the specified request attribute. The default value is false. (Optional)

A sample code snippet, from a JSP named catalogTemplate.jsp, is shown here:

 <%@ taglib uri="/WEB-INF/tlds/struts-template.tld"   prefix="template" %> <html>   <body>     <table>       <tr valign="top">         <td><template:get name="navbar" /></td>         <td>           <table>             <tr><td><template:get name="header" /></td></tr>             <tr><td><template:get name="body" /></td></tr>             <tr><td><template:get name="footer" /></td></tr>           </table>         </td>       </tr>     </table>   </body> </html> 

This JSP defines a template with four parameterized tags: navbar, header, body, and footer. This JSP will first be evaluated, and the <template:get /> tag instances will be replaced by the named request attributes. Then, it will be inserted into a JSP that names it using the <template:insert /> tag. You will see an example of the <template:insert /> tag in the following section.



 < 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