husted      01/02/11 14:57:46

  Modified:    src/share/org/apache/struts/taglib/logic package.html
  Log:
  Change file format to Unix to help with single spacing <pre> blocks.
  
  Revision  Changes    Path
  1.5       +399 -389  
jakarta-struts/src/share/org/apache/struts/taglib/logic/package.html
  
  Index: package.html
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/logic/package.html,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- package.html      2001/01/10 23:39:13     1.4
  +++ package.html      2001/02/11 22:57:46     1.5
  @@ -1,389 +1,399 @@
  -<html>
  -<head>
  -<title>Package Documentation for org.apache.struts.taglib.logic Package</title>
  -</head>
  -<body bgcolor="white">
  -     
  -     <p>
  -             The "struts-bean" tag library contains tags that are useful in 
managing conditional
  -             generation of output text, looping over object collections for 
repetitive generation
  -             of output text, and application flow management
  -     </p>
  -     <a name="doc.Description"></a>
  -     
  -     <p>
  -             
  -<div align="center"> <a href="#doc.Introduction">[Introduction]</a> <a 
href="#doc.Functionality">[Logic 
  -  Functionality]</a> <a href="#doc.Properties">[Logic Properties]</a> <a 
href="#doc.Examples">[Logic 
  -  Examples]</a> </div>
  -     <p></p>
  -     
  -     <hr />
  -<a name="doc.Intro"></a> 
  -<h3>Introduction<a name="doc.Introduction"></a></h3>
  -     
  -     <p>
  -             The Logic library supplies tags that are useful for manipulating 
presentation logic
  -             without the use of scriptlets.
  -     </p>
  -     
  -     
  -<a name="doc.Functionality"></a> 
  -<h3>Logic Tag Functionality<a name="doc.Functionality"></a></h3>
  -<p> The functionality of the logic tags can be divided into four groups:</p>
  -<p><b>Value Comparisions -</b> The purpose of these tags is to print out the body 
  -  of the tag if the comparision evaluates to <i>true. </i></p>
  -<ul>
  -  <li><b><a href="/struts-logic.html#equal">equal,</a> <a 
href="/struts-logic.html#notEqual">notEqual</a></b> 
  -  </li>
  -  <li><b><a href="/struts-logic.html#greaterEqual">greaterEqual</a>, <a 
href="/struts-logic.html#lessEqual">lessEqual</a></b></li>
  -  <li><b><a href="/struts-logic.html#greaterThan">greaterThan</a>,<a 
href="/struts-logic.html#lessThan"> 
  -    lessThan</a></b></li>
  -</ul>
  -<p><b>Substring Matching -</b> The purpose of these tags is to match substrings 
  -  inside of other Strings</p>
  -<ul>
  -  <li><b><a href="/struts-logic.html#match">match</a>, <a 
href="/struts-logic.html#notMatch">notMatch</a></b></li>
  -</ul>
  -<p><b>Presentation Location -</b> The purpose of these tags is to change the 
location 
  -  of the presentation page</p>
  -<ul>
  -  <li><a href="/struts-logic.html#forward"><b>forward</b></a></li>
  -  <li><a href="/struts-logic.html#redirect"><b>redirect</b></a></li>
  -</ul>
  -<p><b>Collection Utilities -</b>The purpose of these tags is to handle 
Collections</p>
  -<ul>
  -  <li><a href="/struts-logic.html#iterate"><b>iterate</b></a> </li>
  -</ul>
  -<h3>Logic Tag Properties<a name="doc.Properties"></a></h3>
  -<p>Each of the four groups of logic tags have a common set of attributes associated 

  -  with them. :</p>
  -<blockquote> 
  -  <p><b>Value Comparisions</b> (equal, notEqual, greaterEqual, lessEqual, 
greaterThan, 
  -    lessThan, present, notPresent)</p>
  -  <p>Each of the value comparision tags takes a <i>value</i> and compares it to 
  -    the value of a comparision attribute. If the value given can be successfully 
  -    converted to a <i>float</i> or <i>double</i>, then a number comparision is 
  -    performed on the value given and the value of the comparision attribute. 
Otherwise 
  -    a String comparision is performed. You have to specify one of the comparision 
  -    attributes: <i>cookie</i>, <i>header</i>, <i>parameter</i>, <i>property</i> 
  -    or <i>name. </i>For each of the examples, the tag 
&quot;<i>someComparisionTag&quot;</i>can 
  -    be replaced by any of the value comparision tags.</p>
  -  <ul>
  -    <li>value - the value to which this tag is going to compare, used in 
conjunction 
  -      with one of the comparision attributes: <i>cookie</i>, <i>header</i>, 
<i>parameter</i>, 
  -      <i>and property</i> and/or <i>name. </i></li>
  -    <li>cookie - the name of the cookie to compare to <i>value</i> 
  -      <ul>
  -        <li>example: 
  -          <pre>&lt;logic:<i>someComparisionTag</i> value=&quot;someUserName&quot; 
cookie=&quot;userName&quot;&gt;
  -     User Logged In
  -&lt;/logic:<i>someComparisionTag</i>&gt;
  -</pre>
  -        </li>
  -      </ul>
  -    </li>
  -    <li>header - the name of the HTTP header to compare to <i>value</i> 
  -      <ul>
  -        <li>example: 
  -          <pre>&lt;logic:<i>someComparisionTag</i> value=&quot;en_US&quot; 
header=&quot;Accept-Language&quot;&gt;
  -     Welcome English-speaking User*
  -&lt;/logic:<i>someComparisionTag</i>&gt;
  -*Note: See the section in the user's guide on <a 
href="../../../../../../building_view.html#i18n">Internationalized Messages</a> to do 
things like this better
  -     </pre>
  -        </li>
  -      </ul>
  -    </li>
  -    <li>name - the variable to be compared to <i>value</i> is the JSP bean 
specified 
  -      by this attribute, if property is not specified, or the value of the 
specified 
  -      property of this bean, if property is specified. 
  -      <ul>
  -        <li>example: 
  -          <pre>&lt;%
  -     String testString = &quot;pantalones&quot;;
  -     pageContext.setAttribute(&quot;testString&quot;, testString, 
PageContext.PAGE_SCOPE);
  -%&gt;
  -&lt;jsp:useBean id=&quot;testString&quot; scope=&quot;page&quot; 
type=&quot;java.lang.String&quot; /&gt;
  -
  -
  -&lt;logic:<i>someComparisionTag</i> name=&quot;testString&quot; 
value=&quot;pantalones&quot;&gt;
  -     Usted tiene pantalones!
  -&lt;/logic:<i>someComparision</i>&gt;</pre>
  -        </li>
  -      </ul>
  -    </li>
  -    <li>parameter - the name of the request parameter to compare to <i>value</i> 
  -      <ul>
  -        <li>example: 
  -          <pre>&lt;logic:<i>someComparisionTag</i> value=&quot;&quot; 
parameter=&quot;username&quot;&gt;
  -     Error: a username must be specified
  -&lt;/logic:<i>someComparisionTag</i>&gt;</pre>
  -        </li>
  -      </ul>
  -    </li>
  -    <li>property - the variable to be compared with <i>value</i> is the property 
  -      (of the bean specified by the name attribute) specified by this attribute. 
  -      The property reference can be simple, nested, and/or indexed. <i>property</i> 

  -      is used in conjunction with <i>name</i> to specify a property in the bean 
  -      specified by <i>name</i>. For the type of syntax used for property, see 
  -      the users guide on the Bean Tags.</li>
  -    <li>scope - the bean scope within which to search for the bean named by the 
  -      name property, or "any scope" if not specified. Possible values are 
&quot;page&quot;, 
  -      &quot;request&quot;, &quot;session&quot;, &quot;application&quot;, or 
&quot;any 
  -      scope&quot; </li>
  -  </ul>
  -  <p><b>Substring Matching</b> (match, notMatch)</p>
  -  <p>The substring matching tags take all the same arguments as the value 
comparision 
  -    tags. You compare the String specified by <i>value</i> to any of the 
comparision 
  -    values you give it, specified by <i>cookie</i>, <i>header</i>, 
<i>parameter</i>, 
  -    <i>property</i> or <i>name.</i> Note that in the examples, <i>matchTag</i> 
  -    corresponds either the <i>match </i>or <i>notMatch</i> tag. Matching tags 
  -    also have an additional <i>location</i> attribute added:</p>
  -  <ul>
  -    <li>location - has two possible values, &quot;start&quot; and &quot;end&quot;. 
  -      If &quot;start&quot;, the substring is attempted to be matched at the 
beginning 
  -      of the String, if &quot;end&quot;, then the substring is attempted to be 
  -      matched to the end of the String 
  -      <ul>
  -        <li>example: 
  -          <pre>&lt;logic:<i>matchTag</i> parameter=&quot;action&quot; 
value=&quot;processLogin&quot;&gt;
  -     Processing Login....
  -&lt;/logic:<i>matchTag</i>&gt;
  -
  -
  -Basically, in this short example, a request parameter &quot;action&quot; 
  -was compared to see if it was equal to the String value &quot;processLogin&quot;.
  -In this case, <i>matchTag</i> would have to be &lt;logic:match&gt;.</pre>
  -        </li>
  -      </ul>
  -    </li>
  -  </ul>
  -  <p><b>Presentation Location</b> (forward, redirect)</p>
  -  <p>The <i>redirect</i> tag is resposible for sending a re-direct to the client's 
  -    browser, complete with URL-rewriting if it's supported by the container. It 
  -    has one argument:</p>
  -  <ul>
  -    <li>href - The context-relative path to forward to</li>
  -  </ul>
  -  <p>The <i>forward</i> tag is responsible for either redirecting or forwarding 
  -    to a specified global action forward. To define a global ActionForward, see 
  -    The <a href="../../../../../../building_controller.html#config">Action Mappings 

  -    Configuration File</a>. You can specify whether the forward re-directs or 
  -    forwards when executed in the config file. The forward tag has one 
attribute:</p>
  -  <ul>
  -    <li>name - The logical name of the ActionForward to use</li>
  -  </ul>
  -  <p><b>Collection Utilities</b> (iterate)</p>
  -  <p>The <i>iterate</i> tag is responsible for executing it's body content once 
  -    for every element inside of the specified Collection. There is one required 
  -    attribute:</p>
  -  <ul>
  -    <li>id - The name of a page scope JSP bean that will contain the current 
element 
  -      of the collection on each iteration</li>
  -  </ul>
  -  <p>The other attributes allow for more flexibility on which Collection to iterate 

  -    and how to do it:</p>
  -  <ul>
  -    <li>collection - a runtime expression that evaluates to a Collection to be 
  -      iterated 
  -      <ul>
  -        <li>example: 
  -          <pre>&lt;%
  -     java.util.Vector vector = new java.util.Vector();
  -     vector.add(new Integer(12));
  -     vector.add(new Integer(5))
  - %&gt;</pre>
  -        </li>
  -      </ul>
  -    </li>
  -  </ul>
  -  <blockquote> 
  -    <blockquote> 
  -      <pre>&lt;bean:iterate id=&quot;myCollectionElement&quot; 
collection=&quot;&lt;% vector %&gt;&quot;&gt;
  -<i>  Do something with myCollectionElement</i>
  -&lt;/bean:iterate&gt;</pre>
  -    </blockquote>
  -  </blockquote>
  -  <ul>
  -    <li>length - The maximum number of entries (from the underlying collection) 
  -      to be iterated through on this page. This can be either an integer that 
  -      directly expresses the desired value, or the name of a JSP bean (in any 
  -      scope) of type java.lang.Integer that defines the desired value. If not 
  -      present, there will be no limit on the number of iterations performed</li>
  -    <li>name - The name of the JSP bean containing the collection to be iterated 
  -      (if property is not specified), or the JSP bean whose property getter returns 

  -      the collection to be iterated (if property is specified). 
  -      <ul>
  -        <li>example: 
  -          <pre>&lt;%<br>    java.util.ArrayList list = new 
java.util.ArrayList();<br>    list.add(&quot;First&quot;);<br>    
list.add(&quot;Second&quot;);<br>    list.add(&quot;Third&quot;);<br>    
list.add(&quot;Fourth&quot;);<br>    list.add(&quot;Fifth&quot;);<br>    
pageContext.setAttribute(&quot;list&quot;, list, PageContext.PAGE_SCOPE);<br> %&gt;
  -
  -&lt;logic:iterate id=&quot;myCollectionElement&quot; name=&quot;list&quot;&gt;
  -     <i>Do something with myCollectionElement</i>
  -&lt;/logic:iterate&gt;</pre>
  -        </li>
  -      </ul>
  -    </li>
  -    <li>offset - The zero-relative index of the starting point at which entries 
  -      from the underlying collection will be iterated through. This can be either 
  -      an integer that directly expresses the desired value, or the name of a JSP 
  -      bean (in any scope) of type java.lang.Integer that defines the desired value. 

  -      If not present, zero is assumed (meaning that the collection will be iterated 

  -      from the beginning. </li>
  -    <li>property - Name of the property, of the JSP bean specified by name, whose 
  -      getter returns the collection to be iterated. See the user's guide for the 
  -      bean tag library for the syntax of the property attribute</li>
  -    <li>scope - The bean scope within which to search for the bean named by the 
  -      name property, or "any scope" if not specified. Possible values are 
&quot;page&quot;, 
  -      &quot;request&quot;, &quot;session&quot;, &quot;application&quot;, or 
&quot;any 
  -      scope&quot; </li>
  -    <li>type - Fully qualified Java class name of the element to be exposed through 

  -      the JSP bean named from the id attribute. If not present, no type conversions 

  -      will be performed. NOTE: The actual elements of the collection must be 
assignment-compatible 
  -      with this class, or a request time ClassCastException will occur. 
  -      <ul>
  -        <li>example: 
  -          <pre>&lt;%<br>    java.util.ArrayList list = new 
java.util.ArrayList();<br>    list.add(&quot;First&quot;);<br>    
list.add(&quot;Second&quot;);<br>    list.add(&quot;Third&quot;);<br>    
list.add(&quot;Fourth&quot;);<br>    list.add(&quot;Fifth&quot;);<br>    
pageContext.setAttribute(&quot;list&quot;, list, PageContext.PAGE_SCOPE);<br> %&gt;
  -
  -&lt;logic:iterate id=&quot;myCollectionElement&quot; name=&quot;list&quot; 
type=&quot;java.lang.String&quot;&gt;
  -     <i>Do something with myCollectionElement</i>
  -&lt;/logic:iterate&gt;</pre>
  -        </li>
  -      </ul>
  -    </li>
  -  </ul>
  -</blockquote>
  -<p>&nbsp;</p>
  -<h3>Logic Examples</h3>
  -<blockquote> 
  -  <p><b>Value Comparisions</b></p>
  -  <blockquote> 
  -    <p><u></u><u></u><u>Logic Equivalence Tags (equal, notEqual, greaterEqual, 
  -      lessEqual, lessThan, greaterThan)</u></p>
  -    <blockquote> 
  -      <p>You can compare these tags to the &quot;==&quot;, &quot;!=&quot; 
,&quot;&gt;=&quot;, 
  -        &quot;&lt;=&quot;, &quot;&lt;&quot;, and &quot;&gt;&quot;logic operators 
  -        in most languages. Their usage is fairly straightforward for numbers. 
  -        For an example, we'll create a small &quot;Guess That Number&quot; game 
  -        that uses request parameters from a form input to play. The number will 
  -        be hardcoded as &quot;7&quot;, because this is just an example. Note that 
  -        this is actually putting application logic inside of jsp pages, and isn't 
  -        the recommended development method for Struts. It's just an easy way to 
  -        show how these tags are used:</p>
  -      <p>The first step is to develop the form that will call on the processing 
  -        jsp page. This form will use the &quot;GET&quot; method so that you can 
  -        see the request parameter in the URL. The POST method can also be used 
  -        with no problem or changes.</p>
  -      <p>[numberGuess.jsp]</p>
  -      <pre>&lt;form action=&quot;numberProcess.jsp&quot; method=&quot;GET&quot;&gt;
  -     Please Enter a Number From 1-10: &lt;input type=&quot;text&quot; 
name=&quot;number&quot; /&gt;&lt;br /&gt;
  -
  -     &lt;center&gt;
  -             &lt;input type=&quot;submit&quot; name=&quot;Guess Number&quot; /&gt;
  -
  -     &lt;/center&gt;
  -&lt;/form&gt;
  -
  -</pre>
  -      The next step is to create the processing page. It uses the struts-logic 
  -      taglib. For information on how to set this tag library up in your application 

  -      to use, see <a 
href="../../../../../../building_controller.html#dd_config">The 
  -      Web Application Deployment Descriptor</a><br>
  -      <br>
  -      <p>[numberProcess.jsp]</p>
  -      <pre>&lt;%@ page language=&quot;java&quot; %&gt;<br>&lt;%@ taglib 
uri=&quot;/WEB-INF/struts-logic.tld&quot; prefix=&quot;logic&quot; %&gt;</pre>
  -      <pre>&lt;!-- Is the number guess right? --&gt;
  -&lt;logic:equal parameter=&quot;number&quot; value=&quot;7&quot;&gt;
  -     You guessed right! You win a high speed blender!
  -&lt;/logic:equal&gt;</pre>
  -      <pre>&lt;!-- If the number guessed was wrong --&gt;
  -&lt;logic:notEqual parameter=&quot;number&quot; value=&quot;7&quot;&gt;
  -     &lt;!-- Less Than --&gt;
  -     &lt;logic:lessThan parameter=&quot;number&quot; value=&quot;7&quot;&gt;
  -         A little higher...
  -     &lt;/logic:lessThan&gt;
  -     &lt;!-- Greater Than --&gt;
  -     &lt;logic:greaterThan parameter=&quot;number&quot; value=&quot;7&quot;&gt;
  -         A little lower...
  -     &lt;/logic:greaterThan&gt;
  -&lt;/logic:notEqual&gt;</pre>
  -      <pre>&nbsp;
  -
  -</pre>
  -      <p>Basically, the numberProcess.jsp page uses the equal tag to check if 
  -        the guess is 7, and if so, prints out a congratulatory message. If the 
  -        number isn't equal, specified by the use of the &lt;logic:notEqual&gt; 
  -        tag, it uses the greaterThan and lessThan tags to check if the number 
  -        is higher or lower than 7, and prints out a hint. As said before, this 
  -        is a horribly designed small application, with no validity checks on the 
  -        number input, but shows the basic usage of the logic equal tags</p>
  -      <p>For String comparisions, the equal tags use the 
java.lang.String.compareTo() 
  -        method. See the javadocs on the compareTo() method for more information, 
  -        located <a 
href="http://www.javasoft.com/products/jdk/1.2/docs/api/java/lang/String.html#compareTo(java.lang.Object)">here</a>.</p>

  -    </blockquote>
  -    <p><u>Match and Present Tags (match, notMatch, present, notPresent)</u></p>
  -    <blockquote> 
  -      <p>You use the match tags in conjunction with the present tags in order 
  -        to do substring matches. For an example using this we'll use headers, 
  -        specifically the &quot;Referer&quot; header. The HTTP referer header gives 
  -        the URL of the document that refers to the requested URL. We'll use this 
  -        to check if the user is coming from a link specified by a <a 
href="http://www.google.com">Google</a> 
  -        search, and offer a personalized greeting, frightening users that find 
  -        our site through the search engine with our amazing intimate knowledge 
  -        of their browsing habits:</p>
  -      <p>[sneaky.jsp]</p>
  -      <pre>&lt;%@ page language=&quot;java&quot; %&gt;
  -&lt;%@ taglib uri=&quot;/WEB-INF/struts-logic.tld&quot; prefix=&quot;logic&quot; 
%&gt;
  -
  -
  -&lt;!-- Check to see if the &quot;Referer&quot; header is present --&gt;
  -&lt;logic:present header=&quot;Referer&quot;&gt;
  -     &lt;logic:match header=&quot;Referer&quot; value=&quot;google.com&quot;&gt;
  -             I see you found our site through Google... interesting.
  -     &lt;/logic:match&gt;
  -     &lt;logic:notMatch header=&quot;Referer&quot; value=&quot;google.com&quot;&gt;
  -             Welcome to the site, we're secretly logging what site you came from,
  -             because we're shady...
  -     &lt;/logic:notMatch&gt;
  -&lt;/logic:present&gt;
  -
  -&lt;!-- If the header is not present --&gt;
  -&lt;logic:notPresent header=&quot;Referer&quot;&gt;
  -     Hi, welcome to our site.  Please fill out our &lt;a 
href=&quot;nonExistantForm.jsp&quot;&gt;Form&lt;/a&gt; and
  -     tell us where you're coming from.
  -&lt;/logic:notPresent&gt;</pre>
  -      <p>Note: Another interesting usage of these tags and headers would be to 
  -        use the &quot;User-Agent&quot; header to display browser-specific 
javascript.</p>
  -    </blockquote>
  -  </blockquote>
  -  <p><b>Collection Utilities (iterate)</b></p>
  -  <blockquote> 
  -    <p>For an example of using the &lt;logic:iterate&gt; tag, we'll use one of 
  -      the previous examples given, in it's entirety. This example uses the 
&lt;bean:write&gt; 
  -      tag from the Bean Tag Library, see the User's Guide on the bean tag library 
  -      for more information on it's usage:</p>
  -    <p>[iterate.jsp]</p>
  -    <pre>&lt;%@ page language=&quot;java&quot; %&gt;<br>&lt;%@ taglib 
uri=&quot;/WEB-INF/struts-bean.tld&quot; prefix=&quot;bean&quot; %&gt;<br>&lt;%@ 
taglib uri=&quot;/WEB-INF/struts-logic.tld&quot; prefix=&quot;logic&quot; %&gt;</pre>
  -  </blockquote>
  -</blockquote>
  -<pre>                &lt;%
  -                     java.util.ArrayList list = new java.util.ArrayList();
  -                     list.add(&quot;First&quot;);
  -                     list.add(&quot;Second&quot;);
  -                     list.add(&quot;Third&quot;);
  -                     list.add(&quot;Fourth&quot;);
  -                     list.add(&quot;Fifth&quot;);
  -                     pageContext.setAttribute(&quot;list&quot;, list, 
PageContext.PAGE_SCOPE);
  -       %&gt;
  -       
  -       &lt;logic:iterate id=&quot;myCollectionElement&quot; 
name=&quot;list&quot;&gt;
  -                     Element Value: &lt;bean:write 
name=&quot;myCollectionElement&quot; /&gt;&lt;br /&gt;
  -       &lt;/logic:iterate&gt;</pre>
  -<blockquote>
  -  <blockquote>&nbsp;</blockquote>
  -</blockquote>
  -</body>
  -</html>
  -                                      
  -                                             
  -             
  -     
  \ No newline at end of file
  +<html>
  +<head>
  +<title>Package Documentation for org.apache.struts.taglib.logic Package</title>
  +</head>
  +<body bgcolor="white">
  +
  +  <p>
  +    The "struts-logic" tag library contains tags that are useful in managing 
conditional
  +    generation of output text, looping over object collections for repetitive 
generation
  +    of output text, and application flow management
  +  </p>
  +  <a name="doc.Description"></a>
  +
  +  <p>
  +
  +<div align="center"> <a href="#doc.Introduction">[Introduction]</a> <a 
href="#doc.Functionality">[Logic
  +  Functionality]</a> <a href="#doc.Properties">[Logic Properties]</a> <a 
href="#doc.Examples">[Logic
  +  Examples]</a> </div>
  +  <p></p>
  +
  +  <hr />
  +<a name="doc.Intro"></a>
  +<h3>Introduction<a name="doc.Introduction"></a></h3>
  +
  +  <p>
  +    The Logic library supplies tags that are useful for manipulating presentation 
logic
  +    without the use of scriptlets.
  +  </p>
  +
  +
  +<a name="doc.Functionality"></a>
  +<h3>Logic Tag Functionality<a name="doc.Functionality"></a></h3>
  +<p> The functionality of the logic tags can be divided into four groups:</p>
  +<p><b>Value Comparisions -</b> The purpose of these tags is to print out the body
  +  of the tag if the comparision evaluates to <i>true. </i></p>
  +<ul>
  +  <li><b><a href="/struts-logic.html#equal">equal,</a> <a 
href="/struts-logic.html#notEqual">notEqual</a></b>
  +  </li>
  +  <li><b><a href="/struts-logic.html#greaterEqual">greaterEqual</a>, <a 
href="/struts-logic.html#lessEqual">lessEqual</a></b></li>
  +  <li><b><a href="/struts-logic.html#greaterThan">greaterThan</a>,<a 
href="/struts-logic.html#lessThan">
  +    lessThan</a></b></li>
  +</ul>
  +<p><b>Substring Matching -</b> The purpose of these tags is to match substrings
  +  inside of other Strings</p>
  +<ul>
  +  <li><b><a href="/struts-logic.html#match">match</a>, <a 
href="/struts-logic.html#notMatch">notMatch</a></b></li>
  +</ul>
  +<p><b>Presentation Location -</b> The purpose of these tags is to change the 
location
  +  of the presentation page</p>
  +<ul>
  +  <li><a href="/struts-logic.html#forward"><b>forward</b></a></li>
  +  <li><a href="/struts-logic.html#redirect"><b>redirect</b></a></li>
  +</ul>
  +<p><b>Collection Utilities -</b>The purpose of these tags is to handle 
Collections</p>
  +<ul>
  +  <li><a href="/struts-logic.html#iterate"><b>iterate</b></a> </li>
  +</ul>
  +<h3>Logic Tag Properties<a name="doc.Properties"></a></h3>
  +<p>Each of the four groups of logic tags have a common set of attributes associated
  +  with them. :</p>
  +<blockquote>
  +  <p><b>Value Comparisions</b> (equal, notEqual, greaterEqual, lessEqual, 
greaterThan,
  +    lessThan, present, notPresent)</p>
  +  <p>Each of the value comparision tags takes a <i>value</i> and compares it to
  +    the value of a comparision attribute. If the value given can be successfully
  +    converted to a <i>float</i> or <i>double</i>, then a number comparision is
  +    performed on the value given and the value of the comparision attribute. 
Otherwise
  +    a String comparision is performed. You have to specify one of the comparision
  +    attributes: <i>cookie</i>, <i>header</i>, <i>parameter</i>, <i>property</i>
  +    or <i>name. </i>For each of the examples, the tag 
&quot;<i>someComparisionTag&quot;</i>can
  +    be replaced by any of the value comparision tags.</p>
  +  <ul>
  +    <li>value - the value to which this tag is going to compare, used in conjunction
  +      with one of the comparision attributes: <i>cookie</i>, <i>header</i>, 
<i>parameter</i>,
  +      <i>and property</i> and/or <i>name. </i></li>
  +    <li>cookie - the name of the cookie to compare to <i>value</i>
  +      <ul>
  +        <li>example:
  +<pre>&lt;logic:<i>someComparisionTag</i> value=&quot;someUserName&quot; 
cookie=&quot;userName&quot;&gt;
  +  User Logged In
  +&lt;/logic:<i>someComparisionTag</i>&gt;
  +</pre>
  +        </li>
  +      </ul>
  +    </li>
  +    <li>header - the name of the HTTP header to compare to <i>value</i>
  +      <ul>
  +        <li>example:
  +<pre>&lt;logic:<i>someComparisionTag</i> value=&quot;en_US&quot; 
header=&quot;Accept-Language&quot;&gt;
  +  Welcome English-speaking User*
  +&lt;/logic:<i>someComparisionTag</i>&gt;
  +</pre></li>
  +<li><p>*Note: See the section in the user's guide on <a 
href="../../../../../../building_view.html#i18n">Internationalized Messages</a> to do 
things like this better.</p></li>
  +      </ul>
  +    </li>
  +    <li>name - the variable to be compared to <i>value</i> is the JSP bean specified
  +      by this attribute, if property is not specified, or the value of the specified
  +      property of this bean, if property is specified.
  +      <ul>
  +        <li>example:
  +<pre>&lt;%
  +  String testString = &quot;pantalones&quot;;
  +  pageContext.setAttribute(&quot;testString&quot;, testString, 
PageContext.PAGE_SCOPE);
  +%&gt;
  +&lt;jsp:useBean id=&quot;testString&quot; scope=&quot;page&quot; 
type=&quot;java.lang.String&quot; /&gt;
  +&lt;logic:<i>someComparisionTag</i> name=&quot;testString&quot; 
value=&quot;pantalones&quot;&gt;
  +  Usted tiene pantalones!
  +&lt;/logic:<i>someComparision</i>&gt;
  +</pre>
  +        </li>
  +      </ul>
  +    </li>
  +    <li>parameter - the name of the request parameter to compare to <i>value</i>
  +      <ul>
  +        <li>example:
  +<pre>&lt;logic:<i>someComparisionTag</i> value=&quot;&quot; 
parameter=&quot;username&quot;&gt;
  +  Error: a username must be specified
  +&lt;/logic:<i>someComparisionTag</i>&gt;
  +</pre>
  +        </li>
  +      </ul>
  +    </li>
  +    <li>property - the variable to be compared with <i>value</i> is the property
  +      (of the bean specified by the name attribute) specified by this attribute.
  +      The property reference can be simple, nested, and/or indexed. <i>property</i>
  +      is used in conjunction with <i>name</i> to specify a property in the bean
  +      specified by <i>name</i>. For the type of syntax used for property, see
  +      the users guide on the Bean Tags.</li>
  +    <li>scope - the bean scope within which to search for the bean named by the
  +      name property, or "any scope" if not specified. Possible values are 
&quot;page&quot;,
  +      &quot;request&quot;, &quot;session&quot;, &quot;application&quot;, or 
&quot;any
  +      scope&quot; </li>
  +  </ul>
  +  <p><b>Substring Matching</b> (match, notMatch)</p>
  +  <p>The substring matching tags take all the same arguments as the value 
comparision
  +    tags. You compare the String specified by <i>value</i> to any of the comparision
  +    values you give it, specified by <i>cookie</i>, <i>header</i>, <i>parameter</i>,
  +    <i>property</i> or <i>name.</i> Note that in the examples, <i>matchTag</i>
  +    corresponds either the <i>match </i>or <i>notMatch</i> tag. Matching tags
  +    also have an additional <i>location</i> attribute added:</p>
  +  <ul>
  +    <li>location - has two possible values, &quot;start&quot; and &quot;end&quot;.
  +      If &quot;start&quot;, the substring is attempted to be matched at the 
beginning
  +      of the String, if &quot;end&quot;, then the substring is attempted to be
  +      matched to the end of the String
  +      <ul>
  +        <li>example:
  +<pre>&lt;logic:<i>matchTag</i> parameter=&quot;action&quot; 
value=&quot;processLogin&quot;&gt;
  +  Processing Login....
  +&lt;/logic:<i>matchTag</i>&gt;
  +
  +Basically, in this short example, a request parameter &quot;action&quot;
  +was compared to see if it was equal to the String value &quot;processLogin&quot;.
  +In this case, <i>matchTag</i> would have to be &lt;logic:match&gt;.
  +</pre>
  +        </li>
  +      </ul>
  +    </li>
  +  </ul>
  +  <p><b>Presentation Location</b> (forward, redirect)</p>
  +  <p>The <i>redirect</i> tag is resposible for sending a re-direct to the client's
  +    browser, complete with URL-rewriting if it's supported by the container. It
  +    has one argument:</p>
  +  <ul>
  +    <li>href - The context-relative path to forward to</li>
  +  </ul>
  +  <p>The <i>forward</i> tag is responsible for either redirecting or forwarding
  +    to a specified global action forward. To define a global ActionForward, see
  +    The <a href="../../../../../../building_controller.html#config">Action Mappings
  +    Configuration File</a>. You can specify whether the forward re-directs or
  +    forwards when executed in the config file. The forward tag has one 
attribute:</p>
  +  <ul>
  +    <li>name - The logical name of the ActionForward to use</li>
  +  </ul>
  +  <p><b>Collection Utilities</b> (iterate)</p>
  +  <p>The <i>iterate</i> tag is responsible for executing it's body content once
  +    for every element inside of the specified Collection. There is one required
  +    attribute:</p>
  +  <ul>
  +    <li>id - The name of a page scope JSP bean that will contain the current element
  +      of the collection on each iteration</li>
  +  </ul>
  +  <p>The other attributes allow for more flexibility on which Collection to iterate
  +    and how to do it:</p>
  +  <ul>
  +    <li>collection - a runtime expression that evaluates to a Collection to be
  +      iterated
  +      <ul>
  +        <li>example:
  +<pre>&lt;%
  +  java.util.Vector vector = new java.util.Vector();
  +  vector.add(new Integer(12));
  +  vector.add(new Integer(5))
  + %&gt;
  +</pre>
  +        </li>
  +      </ul>
  +    </li>
  +  </ul>
  +  <blockquote>
  +    <blockquote>
  +<pre>&lt;bean:iterate id=&quot;myCollectionElement&quot; collection=&quot;&lt;% 
vector %&gt;&quot;&gt;
  +<i> Do something with myCollectionElement</i>
  +&lt;/bean:iterate&gt;
  +</pre>
  +    </blockquote>
  +  </blockquote>
  +  <ul>
  +    <li>length - The maximum number of entries (from the underlying collection)
  +      to be iterated through on this page. This can be either an integer that
  +      directly expresses the desired value, or the name of a JSP bean (in any
  +      scope) of type java.lang.Integer that defines the desired value. If not
  +      present, there will be no limit on the number of iterations performed</li>
  +    <li>name - The name of the JSP bean containing the collection to be iterated
  +      (if property is not specified), or the JSP bean whose property getter returns
  +      the collection to be iterated (if property is specified).
  +      <ul>
  +        <li>example:
  +<pre>&lt;%<br>
  +    java.util.ArrayList list = new java.util.ArrayList();
  +    list.add(&quot;First&quot;);
  +    list.add(&quot;Second&quot;);
  +    list.add(&quot;Third&quot;);
  +    list.add(&quot;Fourth&quot;);
  +    list.add(&quot;Fifth&quot;);
  +    pageContext.setAttribute(&quot;list&quot;, list, PageContext.PAGE_SCOPE);
  +%&gt;
  +
  +&lt;logic:iterate id=&quot;myCollectionElement&quot; name=&quot;list&quot;&gt;
  +  <i>Do something with myCollectionElement</i>
  +&lt;/logic:iterate&gt;</pre>
  +        </li>
  +      </ul>
  +    </li>
  +    <li>offset - The zero-relative index of the starting point at which entries
  +      from the underlying collection will be iterated through. This can be either
  +      an integer that directly expresses the desired value, or the name of a JSP
  +      bean (in any scope) of type java.lang.Integer that defines the desired value.
  +      If not present, zero is assumed (meaning that the collection will be iterated
  +      from the beginning. </li>
  +    <li>property - Name of the property, of the JSP bean specified by name, whose
  +      getter returns the collection to be iterated. See the user's guide for the
  +      bean tag library for the syntax of the property attribute</li>
  +    <li>scope - The bean scope within which to search for the bean named by the
  +      name property, or "any scope" if not specified. Possible values are 
&quot;page&quot;,
  +      &quot;request&quot;, &quot;session&quot;, &quot;application&quot;, or 
&quot;any
  +      scope&quot; </li>
  +    <li>type - Fully qualified Java class name of the element to be exposed through
  +      the JSP bean named from the id attribute. If not present, no type conversions
  +      will be performed. NOTE: The actual elements of the collection must be 
assignment-compatible
  +      with this class, or a request time ClassCastException will occur.
  +      <ul>
  +        <li>example:
  +<pre>&lt;%    java.util.ArrayList list = new java.util.ArrayList();
  +list.add(&quot;First&quot;);
  +list.add(&quot;Second&quot;);
  +list.add(&quot;Third&quot;);
  +list.add(&quot;Fourth&quot;);
  +list.add(&quot;Fifth&quot;);
  +    pageContext.setAttribute(&quot;list&quot;, list, PageContext.PAGE_SCOPE);
  + %&gt;
  +
  +&lt;logic:iterate id=&quot;myCollectionElement&quot; name=&quot;list&quot; 
type=&quot;java.lang.String&quot;&gt;
  +  <i>Do something with myCollectionElement</i>
  +&lt;/logic:iterate&gt;</pre>
  +        </li>
  +      </ul>
  +    </li>
  +  </ul>
  +</blockquote>
  +<h3>Logic Examples</h3>
  +<blockquote>
  +  <p><b>Value Comparisions</b></p>
  +  <blockquote>
  +    <p><u></u><u></u><u>Logic Equivalence Tags (equal, notEqual, greaterEqual,
  +      lessEqual, lessThan, greaterThan)</u></p>
  +    <blockquote>
  +      <p>You can compare these tags to the &quot;==&quot;, &quot;!=&quot; 
,&quot;&gt;=&quot;,
  +        &quot;&lt;=&quot;, &quot;&lt;&quot;, and &quot;&gt;&quot;logic operators
  +        in most languages. Their usage is fairly straightforward for numbers.
  +        For an example, we'll create a small &quot;Guess That Number&quot; game
  +        that uses request parameters from a form input to play. The number will
  +        be hardcoded as &quot;7&quot;, because this is just an example. Note that
  +        this is actually putting application logic inside of jsp pages, and isn't
  +        the recommended development method for Struts. It's just an easy way to
  +        show how these tags are used:</p>
  +      <p>The first step is to develop the form that will call on the processing
  +        jsp page. This form will use the &quot;GET&quot; method so that you can
  +        see the request parameter in the URL. The POST method can also be used
  +        with no problem or changes.</p>
  +      <p>[numberGuess.jsp]</p>
  +<pre>&lt;form action=&quot;numberProcess.jsp&quot; method=&quot;GET&quot;&gt;
  +Please Enter a Number From 1-10: &lt;input type=&quot;text&quot; 
name=&quot;number&quot; /&gt;&lt;br /&gt;
  +  &lt;center&gt;
  +    &lt;input type=&quot;submit&quot; name=&quot;Guess Number&quot; /&gt;
  +  &lt;/center&gt;
  +&lt;/form&gt;
  +</pre>
  +      The next step is to create the processing page. It uses the struts-logic
  +      taglib. For information on how to set this tag library up in your application
  +      to use, see <a href="../../../../../../building_controller.html#dd_config">The
  +      Web Application Deployment Descriptor</a>
  +
  +      <p>[numberProcess.jsp]</p>
  +<pre>&lt;%@ page language=&quot;java&quot; %&gt;
  +&lt;%@ taglib uri=&quot;/WEB-INF/struts-logic.tld&quot; prefix=&quot;logic&quot; 
%&gt;
  +</pre>
  +<pre>&lt;!-- Is the number guess right? --&gt;
  +&lt;logic:equal parameter=&quot;number&quot; value=&quot;7&quot;&gt;
  +  You guessed right! You win a high speed blender!
  +&lt;/logic:equal&gt;
  +</pre>
  +<pre>&lt;!-- If the number guessed was wrong --&gt;
  +&lt;logic:notEqual parameter=&quot;number&quot; value=&quot;7&quot;&gt;
  +  &lt;!-- Less Than --&gt;
  +  &lt;logic:lessThan parameter=&quot;number&quot; value=&quot;7&quot;&gt;
  +         A little higher...
  +  &lt;/logic:lessThan&gt;
  +  &lt;!-- Greater Than --&gt;
  +  &lt;logic:greaterThan parameter=&quot;number&quot; value=&quot;7&quot;&gt;
  +         A little lower...
  +  &lt;/logic:greaterThan&gt;
  +&lt;/logic:notEqual&gt;
  +</pre>
  +      <p>Basically, the numberProcess.jsp page uses the equal tag to check if
  +        the guess is 7, and if so, prints out a congratulatory message. If the
  +        number isn't equal, specified by the use of the &lt;logic:notEqual&gt;
  +        tag, it uses the greaterThan and lessThan tags to check if the number
  +        is higher or lower than 7, and prints out a hint. As said before, this
  +        is a horribly designed small application, with no validity checks on the
  +        number input, but shows the basic usage of the logic equal tags</p>
  +      <p>For String comparisions, the equal tags use the 
java.lang.String.compareTo()
  +        method. See the javadocs on the compareTo() method for more information,
  +        located <a 
href="http://www.javasoft.com/products/jdk/1.2/docs/api/java/lang/String.html#compareTo(java.lang.Object)">here</a>.</p>
  +    </blockquote>
  +    <p><u>Match and Present Tags (match, notMatch, present, notPresent)</u></p>
  +    <blockquote>
  +      <p>You use the match tags in conjunction with the present tags in order
  +        to do substring matches. For an example using this we'll use headers,
  +        specifically the &quot;Referer&quot; header. The HTTP referer header gives
  +        the URL of the document that refers to the requested URL. We'll use this
  +        to check if the user is coming from a link specified by a <a 
href="http://www.google.com">Google</a>
  +        search, and offer a personalized greeting, frightening users that find
  +        our site through the search engine with our amazing intimate knowledge
  +        of their browsing habits:</p>
  +      <p>[sneaky.jsp]</p>
  +      <pre>&lt;%@ page language=&quot;java&quot; %&gt;
  +&lt;%@ taglib uri=&quot;/WEB-INF/struts-logic.tld&quot; prefix=&quot;logic&quot; 
%&gt;
  +
  +
  +&lt;!-- Check to see if the &quot;Referer&quot; header is present --&gt;
  +&lt;logic:present header=&quot;Referer&quot;&gt;
  +  &lt;logic:match header=&quot;Referer&quot; value=&quot;google.com&quot;&gt;
  +    I see you found our site through Google... interesting.
  +  &lt;/logic:match&gt;
  +  &lt;logic:notMatch header=&quot;Referer&quot; value=&quot;google.com&quot;&gt;
  +    Welcome to the site, we're secretly logging what site you came from,
  +    because we're shady...
  +  &lt;/logic:notMatch&gt;
  +&lt;/logic:present&gt;
  +
  +&lt;!-- If the header is not present --&gt;
  +&lt;logic:notPresent header=&quot;Referer&quot;&gt;
  +  Hi, welcome to our site.  Please fill out our 
  +  &lt;a href=&quot;nonExistantForm.jsp&quot;&gt;Form&lt;/a&gt; and
  +  tell us where you're coming from.
  +&lt;/logic:notPresent&gt;</pre>
  +      <p>Note: Another interesting usage of these tags and headers would be to
  +        use the &quot;User-Agent&quot; header to display browser-specific 
javascript.</p>
  +    </blockquote>
  +  </blockquote>
  +  <p><b>Collection Utilities (iterate)</b></p>
  +  <blockquote>
  +    <p>For an example of using the &lt;logic:iterate&gt; tag, we'll use one of
  +      the previous examples given, in it's entirety. This example uses the 
&lt;bean:write&gt;
  +      tag from the Bean Tag Library, see the User's Guide on the bean tag library
  +      for more information on it's usage:</p>
  +    <p>[iterate.jsp]</p>
  +<pre>&lt;%@ page language=&quot;java&quot; %&gt;
  +&lt;%@ taglib uri=&quot;/WEB-INF/struts-bean.tld&quot; prefix=&quot;bean&quot; %&gt;
  +&lt;%@ taglib uri=&quot;/WEB-INF/struts-logic.tld&quot; prefix=&quot;logic&quot; 
%&gt;
  +</pre>
  +<pre>&lt;%
  +java.util.ArrayList list = new java.util.ArrayList();
  +  list.add(&quot;First&quot;);
  +  list.add(&quot;Second&quot;);
  +  list.add(&quot;Third&quot;);
  +  list.add(&quot;Fourth&quot;);
  +  list.add(&quot;Fifth&quot;);
  +  pageContext.setAttribute(&quot;list&quot;, list, PageContext.PAGE_SCOPE);
  +%&gt;
  +
  +&lt;logic:iterate id=&quot;myCollectionElement&quot; name=&quot;list&quot;&gt;
  +  Element Value: &lt;bean:write name=&quot;myCollectionElement&quot; /&gt;&lt;br 
/&gt;
  +&lt;/logic:iterate&gt;</pre>
  +</blockquote>
  +</blockquote>
  +</body>
  +</html>
  
  
  

Reply via email to