You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2017/04/02 09:13:11 UTC

[10/13] struts-site git commit: cleaned up control-tags page

cleaned up control-tags page


Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/9ee4d154
Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/9ee4d154
Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/9ee4d154

Branch: refs/heads/master
Commit: 9ee4d15426f1d903708db0b3516a72f953867137
Parents: 4d57b53
Author: Stefaan Dutry <st...@gmail.com>
Authored: Sun Apr 2 09:50:47 2017 +0200
Committer: Stefaan Dutry <st...@gmail.com>
Committed: Sun Apr 2 09:50:47 2017 +0200

----------------------------------------------------------------------
 source/getting-started/control-tags.md | 62 +++++++++++------------------
 1 file changed, 24 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-site/blob/9ee4d154/source/getting-started/control-tags.md
----------------------------------------------------------------------
diff --git a/source/getting-started/control-tags.md b/source/getting-started/control-tags.md
index eb8e54e..edcc083 100644
--- a/source/getting-started/control-tags.md
+++ b/source/getting-started/control-tags.md
@@ -6,34 +6,26 @@ title: Control tags
 
 The example code for this tutorial, control_tags, is available at [https://github.com/apache/struts-examples](https://github.com/apache/struts-examples)
 
-> 
+__Introduction__
 
-#####Introduction#####
+Struts 2 has several control tags that can be used in the view. This tutorial will discuss and show examples of how to use the Struts 2 if and iterator tags. For more information about these and other control tags visit [tags reference](http://cwiki.apache.org/confluence/display/WW/Generic+Tag+Reference).
 
-Struts 2 has several control tags that can be used in the view. This tutorial will discuss and show examples of how to use the Struts 2 if and iterator tags. For more information about these and other control tags visit [tags reference](http://cwiki.apache.org/confluence/display/WW/Generic\+Tag\+Reference)^[http://cwiki.apache.org/confluence/display/WW/Generic\+Tag\+Reference].
+The [Struts 2 user mailing list](http://struts.apache.org/mail.html) is an excellent place to get help. If you are having a problem getting the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
 
-
-
-| The [Struts 2 user mailing list](http://struts.apache.org/mail.html)^[http://struts.apache.org/mail.html] is an excellent place to get help. If you are having a problem getting the tutorial example applications to work search the Struts 2 mailing list. If you don't find an answer to your problem, post a question on the mailing list.
-
-| 
-
-#####Struts 2 if Tag#####
+__Struts 2 if Tag__
 
 In the example application's thankyou.jsp is this markup.
 
 **thankyou.jsp Struts if Tag**
 
-
-~~~~~~~
+```html
 <s:if test="personBean.over21">
     <p>You are old enough to vote!</p>
 </s:if>
 <s:else>
    <p>You are NOT old enough to vote.</p>
 </s:else>
-
-~~~~~~~
+```
 
 The Struts if tag has a test attribute. The value of the test attribute must evaluate to true or false. If true the statements between the opening and closing s:if tags will be executed. If false, the statements between the opening and closing s:else tags will be executed. Note that s:else tags come after the closing s:if tag and that the s:else tags are not required.
 
@@ -41,53 +33,47 @@ In the above example the Struts framework will call method getPersonBean exposed
 
 The value of the test attribute must be an expression that evaluates to true or false, but doesn't need to be a method call that returns a boolean. For example this s:if tag that is in thankyou.jsp has a more complicated expression.
 
-
-~~~~~~~
+```html
 <s:if test="personBean.carModels.length > 1">
-	<p>Car models
+    <p>Car models
 </s:if>
 <s:else>
    <p>Car model
 </s:else>
-
-~~~~~~~
+```
 
 The purpose of the above markup is to use either "Car model" or "Car models" depending on how many car models the user selected on the edit page. So the value for the test attribute of this iterator tag gets the length of the carModels String array and compares that to 1. If it's greater then 1, the correct grammar is "Car models" else the correct grammar is "Car model".
 
-#####Struts iterator Tag#####
+__Struts iterator Tag__
 
 The Struts iterator tag is used to generate a loop that iterates over each item in a collection. In the thankyou.jsp is this markup.
 
-
-~~~~~~~
+```html
 <table style="margin-left:15px">
-	<s:iterator value="personBean.carModels">
-		<tr><td><s:property /></td></tr>
-	</s:iterator>
+    <s:iterator value="personBean.carModels">
+        <tr><td><s:property /></td></tr>
+    </s:iterator>
 </table>
-
-~~~~~~~
+```
 
 The goal of this code is to create an HTML table with a row that display a car model selected by the user on the edit page. The car models the user selects on the edit page are stored in the carModels field (a String array) of the personBean object (of class Person).
 
 The iterator tag has a value attribute that must evaluate to a collection (Array, List, Map).
 
-The s:property tag nested inside the iterator tag is used to display the specific value of the collection each time the iterator loops over an element of the collection. Since the collection is an Array of String objects, the s:property tag doesn't need to specify a value attribute. By default the s:property tag will display the single String for that element of the collection.
+The `s:property` tag nested inside the iterator tag is used to display the specific value of the collection each time the iterator loops over an element of the collection. Since the collection is an Array of String objects, the `s:property` tag doesn't need to specify a value attribute. By default the `s:property` tag will display the single String for that element of the collection.
 
 If the collection contains objects that have multiple fields, then you should use the value attribute of the s:property tag to determine what field to display. For example:
 
-
-~~~~~~~
+```html
 <table style="margin-left:15px">
-	<s:iterator value="states" >	
-		<tr><td><s:property value="stateAbbr" /></td> <td><s:property value="stateName" /></tr>
-	</s:iterator>
+    <s:iterator value="states" >	
+        <tr><td><s:property value="stateAbbr" /></td> <td><s:property value="stateName" /></tr>
+    </s:iterator>
 </table>
+```
 
-~~~~~~~
-
-The value of the iterator tag is states, which causes the Struts 2 framework to call the getStates method of the Action class (EditAction.java). The getStates method returns a List of State objects. The State class has two fields stateAbbr and stateName, both having the appropriate get method. The iterator will loop over each State object stored in the collection. Each time through the loop, the Struts 2 framework will have a reference to the current State object and will call getStateAbbr and getStateName methods for that current State object.
+The value of the iterator tag is states, which causes the Struts 2 framework to call the getStates method of the Action class (`EditAction.java`). The getStates method returns a List of State objects. The State class has two fields stateAbbr and stateName, both having the appropriate get method. The iterator will loop over each State object stored in the collection. Each time through the loop, the Struts 2 framework will have a reference to the current State object and will call getStateAbbr and getStateName methods for that current State object.
 
-#####Additional Iterator Attributes#####
+__Additional Iterator Attributes__
 
-The Struts 2 iterator tag has additional attributes you can use to control the begin and end values for specifying that the iterator tag should only loop over a part of the collection. See the [iterator tag reference](https://cwiki.apache.org/confluence/display/WW/iterator)^[https://cwiki.apache.org/confluence/display/WW/iterator] for more information.
+The Struts 2 iterator tag has additional attributes you can use to control the begin and end values for specifying that the iterator tag should only loop over a part of the collection. See the [iterator tag reference](https://cwiki.apache.org/confluence/display/WW/iterator) for more information.