⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 struts-nested.html

📁 struts api,学习使用struts必备的文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>The Struts Framework Project - Nested Tags</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="Arron Bates" name="author" />
<link href="../struts.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="heading">
<a href="http://apache.org/">
<img id="asf_logo_wide" alt="The Apache Project" src="../images/asf_logo_wide.gif" />
</a>
<a href="http://struts.apache.org/">
<img id="struts-logo" alt="Struts Framework" src="../images/struts.gif" />
</a>
</div>
<!--end heading-->
<div id="content">
<div id="menu">

    
    
    <p>User Guide</p>
<ul>
      <li>
<a href="index.html">Table of Contents</a>
</li>
      <li>
<a href="preface.html">Preface</a>
</li>
      <li>
<a href="introduction.html">Introduction</a>
</li>
      <li>
<a href="building_model.html">Model Components</a>
</li>
      <li>
<a href="building_view.html">View Components</a>
</li>
      <li>
<a href="building_controller.html">Controller Components</a>
</li>
      <li>
<a href="configuration.html">Configuration</a>
</li>
      <li>
<a href="release-notes.html">Release Notes</a>
</li>
      <li>
<a href="installation.html">Installation</a>
</li>
    </ul>

    <p>Developer Guides</p>
<ul>
        <li>
<a href="dev_bean.html">Bean Tags</a>
</li>
        <li>
<a href="dev_html.html">HTML Tags</a>
</li>
        <li>
<a href="dev_logic.html">Logic Tags</a>
</li>
        <li>
<a href="dev_nested.html">Nested Tags</a>
</li>
        <li>
<a href="dev_tiles.html">Tiles Tags</a>
</li>
        <li>
<a href="dev_util.html">Utilities</a>
</li>
        <li>
<a href="dev_validator.html">Validator</a>
</li>
    </ul>

    <p>Quick Links</p>
<ul>
        <li>
<a href="../index.html">Welcome</a>
</li>
        <li>
<a href="index.html">User and Developer Guides *</a>
</li>
        <li>
<a href="../faqs/index.html">FAQs and HowTos</a>
</li>
    </ul>

</div>
<!--end menu-->
<div id="main">

<h2 id="top">Struts Nested Tags</h2>
<div class="indent">
    <p>[Since Struts 1.1]</p>
    <p>This tag library brings a nested context to the functionality of the
    Struts custom tag library.</p>

    <p>It's written in a layer that extends the current Struts tags, building on
    their logic and functionality. The layer enables the tags to be aware of the
    tags which surround them so they can correctly provide the nesting property
    reference to the Struts system.
    </p>

    <p>
<strong>It's all about nesting beans...</strong>
<br />
    A bean holds a reference to another bean internally, and all access to that
    bean is handled through the current bean. This act of having one bean's
    access go through another bean is known as "nesting beans". The first bean
    is known as the parent bean. The bean which it references, is known as a
    child bean. The terms "parent" and "child" are commonly used to describe the
    model's hierarchy.
    </p>

    <p>
<strong>A simple example... </strong>
<br />
     Take an object which represents a monkey. The monkey's job is to pick
     bunches of bananas. On each bunch picked hangs many bananas. If this case
     was translated to bean objects, the monkey object would have a reference to
     the bunch objects he picked, and each bunch object would hold a reference
     to the bananas hanging in the bunch.
    </p>

    <p>
<strong>To describe this... </strong>
<br />
     The monkey object is the parent to the bunch object, and the bunch object
     is a child of the monkey object. The bunch object is parent to its child
     banana objects, and the child banana objects children of the bunch object.
     The monkey is higher in the hierarchy than the bananas, and the bananas
     lower in the hierarchy to the bunches.
     </p>

    <p>One special term to remember is for the most parent class, which is known
    as the "root" object which starts the hierarchy.</p>

    <p>Nested tags are all about efficiently managing this style of hierarchy
    structure within your JSP markup.</p>

    <p>
    <strong>Important Note:</strong> Nearly all these tags extend tags from
    other libraries to bring their functionality into the nested context.
    Nesting relies on the tags working against the one bean model, and managing
    the properties so that they become relative to the properties they are
    nested within. In doing so, the tags will set the "name" attribute internally
    (where applicable), and in many cases will rely on the "property" attribute
    being set so it can be updated internally to become nested. The original tags
    on occasion provide options that don't use the "name" and "property"
    attributes. These uses will then fall outside the nested context, and will
    most likely cause error. To take advantage of these options, markup using
    the original tag for these cases. For an example see the
    <a href="#options">
<code>&lt;nested:options&gt;</code>
</a> tag.
    </p>
  <table class="taglib-summary">
<thead>
<tr>
<th>Tag Name</th>
<th>Description</th>
</tr>
</thead>
<tr class="evenRow">
<td align="center">
<a href="#nest">nest</a>
</td>
<td>
      Defines a new level of nesting for child tags to reference to
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#writeNesting">writeNesting</a>
</td>
<td>
      Writes or makes a scripting variable of the current nesting level.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#root">root</a>
</td>
<td>To start off a nested hierarchy without the need for a form</td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#define">define</a>
</td>
<td>Nested Extension -
      Define a scripting variable based on the value(s) of the specified
      bean property.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#message">message</a>
</td>
<td>Nested Extension -
    Render an internationalized message string to the response.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#size">size</a>
</td>
<td>Nested Extension -
      Define a bean containing the number of elements in a Collection or Map.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#write">write</a>
</td>
<td>Nested Extension -
    Render the value of the specified bean property to the current
    JspWriter.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#checkbox">checkbox</a>
</td>
<td>Nested Extension - Render A Checkbox Input Field</td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#errors">errors</a>
</td>
<td>
        Nested Extension - Conditionally display a set of accumulated error messages.
     </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#file">file</a>
</td>
<td>Nested Extension -
      Render A File Select Input Field
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#form">form</a>
</td>
<td>Nested Extension - Define An Input Form</td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#hidden">hidden</a>
</td>
<td>Nested Extension -
        Render A Hidden Field
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#image">image</a>
</td>
<td>Nested Extension -
    Render an input tag of type "image"
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#img">img</a>
</td>
<td>Nested Extension - Render an HTML "img" tag</td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#link">link</a>
</td>
<td>Nested Extension - Render an HTML anchor or hyperlink</td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#messages">messages</a>
</td>
<td>
         Nested Extension - Conditionally display a set of accumulated messages.
      </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#multibox">multibox</a>
</td>
<td>Nested Extension -
        Render A Checkbox Input Field
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#options">options</a>
</td>
<td>Nested Extension - Render a Collection of Select Options</td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#optionsCollection">optionsCollection</a>
</td>
<td>Nested Extension -
        Render a Collection of Select Options
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#password">password</a>
</td>
<td>Nested Extension -
        Render A Password Input Field
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#radio">radio</a>
</td>
<td>Nested Extension -
        Render A Radio Button Input Field
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#select">select</a>
</td>
<td>Nested Extension -
    Render A Select Element
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#submit">submit</a>
</td>
<td>Nested Extension - Render A Submit Button</td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#text">text</a>
</td>
<td>Nested Extension -
        Render An Input Field of Type text
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#textarea">textarea</a>
</td>
<td>Nested Extension - Render A Textarea</td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#empty">empty</a>
</td>
<td>Nested Extension -
    Evaluate the nested body content of this tag if the requested variable is
    either null or an empty string.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#equal">equal</a>
</td>
<td>Nested Extension -
    Evaluate the nested body content of this tag if the requested
    variable is equal to the specified value.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#greaterEqual">greaterEqual</a>
</td>
<td>Nested Extension - Evaluate the nested body content of this tag if the requested
    variable is greater than or equal to the specified value.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#greaterThan">greaterThan</a>
</td>
<td>Nested Extension -
      Evaluate the nested body content of this tag if the requested
      variable is greater than the specified value.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#iterate">iterate</a>
</td>
<td>Nested Extension -
      Repeat the nested body content of this tag over a specified collection.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#lessEqual">lessEqual</a>
</td>
<td>Nested Extension -
      Evaluate the nested body content of this tag if the requested
      variable is greater than or equal to the specified value.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#lessThan">lessThan</a>
</td>
<td>Nested Extension -
      Evaluate the nested body content of this tag if the requested
      variable is less than the specified value.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#match">match</a>
</td>
<td>Nested Extension -
      Evaluate the nested body content of this tag if the specified value
      is an appropriate substring of the requested variable.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#messagesNotPresent">messagesNotPresent</a>
</td>
<td>
       Nested Extension -
       Generate the nested body content of this tag if the specified
       message is not present in this request.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#messagesPresent">messagesPresent</a>
</td>
<td>
       Nested Extension -
       Generate the nested body content of this tag if the specified
       message is present in this request.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#notEmpty">notEmpty</a>
</td>
<td>Nested Extension -
      Evaluate the nested body content of this tag if the requested variable is
      neither null nor an empty string.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#notEqual">notEqual</a>
</td>
<td>Nested Extension -
      Evaluate the nested body content of this tag if the requested
      variable is not equal to the specified value.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#notMatch">notMatch</a>
</td>
<td>Nested Extension -
      Evaluate the nested body content of this tag if the specified value
      is not an appropriate substring of the requested variable.
    </td>
</tr>
<tr class="evenRow">
<td align="center">
<a href="#notPresent">notPresent</a>
</td>
<td>Nested Extension -
      Generate the nested body content of this tag if the specified
      value is not present in this request.
    </td>
</tr>
<tr class="oddRow">
<td align="center">
<a href="#present">present</a>
</td>
<td>Nested Extension -
      Generate the nested body content of this tag if the specified
      value is present in this request.
    </td>
</tr>
</table>
</div>
<h3 id="nest">
<strong>nest</strong> - 
      Defines a new level of nesting for child tags to reference to
    </h3>
<div class="indent">
      <p>
      This tag provides a simple method of defining a logical nesting level in
      the nested hierarchy. It run no explicit logic, is simply a place holder.
      It also means you can remove the need for explicit setting of level
      properties in child tags.
      </p>
      <p>
      Just as the iterate tag provide a parent to other tags, this does the same
      but there is no logic for iterating or otherwise.
      </p>
      <p>
      Example...</p>
      <pre>
&lt;nested:write property="myNestedLevel.propertyOne" /&gt;
&lt;nested:write property="myNestedLevel.propertyTwo" /&gt;
&lt;nested:write property="myNestedLevel.propertyThree" /&gt;
      </pre>
      <p>Can instead become...</p>
      <pre>
&lt;nested:nest property="myNestedLevel" &gt;
  &lt;nested:write property="propertyOne" /&gt;
  &lt;nested:write property="propertyTwo" /&gt;
  &lt;nested:write property="propertyThree" /&gt;
&lt;/nested:nest &gt;
      </pre>
    <table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tr class="evenRow">
<td align="center">property</td>
<td>
        This specifies the property by which this tag and all child tags
        will be relative to.
      
            [RT Expr]
          </td>
</tr>
</table>
</div>
<p>
<a href="#top">Back to top</a>
</p>
<h3 id="writeNesting">
<strong>writeNesting</strong> - 
      Writes or makes a scripting variable of the current nesting level.
    </h3>
<div class="indent">
      This tag provides a way of accessing the nested property reference used by
      the nested tags. Can expose a scripting variable, or simply write out the
      value.
    <table class="tag-attributes">
<thead>
<tr>
<th class="attribute">Attribute Name</th>
<th>Description</th>
</tr>
</thead>
<tr class="evenRow">
<td align="center">property</td>
<td>
        If not supplied, will simply write out as if "./" or "this/" was supplied.
      
            [RT Expr]
          </td>
</tr>
<tr class="oddRow">
<td align="center">id</td>
<td>
        If <i>id</i> is supplied, then what would have been written out into the
        response stream, will instead be made available as a String object
        defined by the variable name provided.
      
            [RT Expr]
          </td>
</tr>
<tr class="evenRow">
<td align="center">filter</td>
<td>
        true/false value, describing to the tag if the result if to be URLEncoded.
        Helps JavaScript along if the result is required for URL hacking.
      
            [RT Expr]
          </td>
</tr>
</table>
</div>
<p>
<a href="#top">Back to top</a>
</p>
<h3 id="root">
<strong>root</strong> - To start off a nested hierarchy without the need for a form</h3>
<div class="indent">
      <p>
        This tag is provided to allow the nested tags to find a common bean
        reference without the need for a form and its relative overhead. As
        long as the <code>name</code> attribute of this tag matches the name
        of a bean in scope of the JSP (ie: Struts tags can find it via usual
        means). For example you can load a bean for use with the
        <code>jsp:useBean</code> tag.
      </p>
      <p>
        The tag can also be used without specifying the <code>name</code>
        attribute, but this is only in the case that the current JSP is a
        dynamic include specified in another file. You will not be able to run
        the tag without a name unless this inclusion is in place. Otherwise
        the nested tags will not have the bean and property references that they
        need to provide their logic.
      </p>
      <p>
        <strong>Note</strong>: The access to a bean via the <code>name</code>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -