struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1009449 [8/10] - in /websites/production/struts/content: ./ bootstrap/css/ fonts/ getting-started/ getting-started/attachments/
Date Fri, 31 Mar 2017 05:44:40 GMT
Added: websites/production/struts/content/getting-started/processing-forms.html
==============================================================================
--- websites/production/struts/content/getting-started/processing-forms.html (added)
+++ websites/production/struts/content/getting-started/processing-forms.html Fri Mar 31 05:44:39 2017
@@ -0,0 +1,449 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8"/>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+  <meta name="Date-Revision-yyyymmdd" content="20140918"/>
+  <meta http-equiv="Content-Language" content="en"/>
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+
+  <title>Processing forms</title>
+
+  <link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic,600italic,700italic" rel="stylesheet" type="text/css">
+  <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
+  <link href="/css/main.css" rel="stylesheet">
+  <link href="/css/custom.css" rel="stylesheet">
+
+  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+  <script type="text/javascript" src="/bootstrap/js/bootstrap.js"></script>
+  <script type="text/javascript" src="/js/community.js"></script>
+</head>
+<body>
+
+<a href="http://github.com/apache/struts" class="github-ribbon">
+  <img style="position: absolute; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub">
+</a>
+
+<header>
+  <nav>
+    <div role="navigation" class="navbar navbar-default navbar-fixed-top">
+      <div class="container">
+        <div class="navbar-header">
+          <button type="button" data-toggle="collapse" data-target="#struts-menu" class="navbar-toggle">
+            Menu
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+          <a href="/index.html" class="navbar-brand logo"><img src="/img/struts-logo.svg"></a>
+        </div>
+        <div id="struts-menu" class="navbar-collapse collapse">
+          <ul class="nav navbar-nav">
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Home<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/index.html">Welcome</a></li>
+                <li><a href="/downloads.html">Downloads</a></li>
+                <li><a href="/announce.html">Announcements</a></li>
+                <li><a href="http://www.apache.org/licenses/">License</a></li>
+                <li><a href="http://apache.org/foundation/thanks.html">Thanks!</a></li>
+                <li><a href="http://apache.org/foundation/sponsorship.html">Sponsorship</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Support<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/mail.html">User Mailing List</a></li>
+                <li><a href="https://issues.apache.org/jira/browse/WW">Issue Tracker</a></li>
+                <li><a href="/security.html">Reporting Security Issues</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/project-info.html">Project info</a></li>
+                <li><a href="/maven/struts2-core/dependencies.html">Struts Core dependencies</a></li>
+                <li><a href="/maven/struts2-plugins/modules.html">Plugin dependencies</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Documentation<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/birdseye.html">Birds Eye</a></li>
+                <li><a href="/primer.html">Key Technologies</a></li>
+                <li><a href="/kickstart.html">Kickstart FAQ</a></li>
+                <li><a href="https://cwiki.apache.org/confluence/display/WW/Home">Wiki</a></li>
+                <li class="divider"></li>
+                <li><a href="/docs/home.html">Getting started</a></li>
+                <li><a href="/docs/tutorials.html">Tutorials</a></li>
+                <li><a href="/docs/faqs.html">FAQs</a></li>
+                <li><a href="/docs/guides.html">Guides</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/struts2-core/apidocs/index.html">Struts Core API</a></li>
+                <li><a href="/docs/plugins.html">Plugin APIs</a></li>
+                <li><a href="/docs/tag-reference.html">Tag reference</a></li>
+                <li><a href="http://cwiki.apache.org/S2PLUGINS/home.html">Plugin registry</a></li>
+                <li class="divider"></li>
+                <li><a href="/getting-started/getting-started.html">Getting Started (WIP)</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Contributing<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/youatstruts.html">You at Struts</a></li>
+                <li><a href="/helping.html">How to Help FAQ</a></li>
+                <li><a href="/dev-mail.html">Development Lists</a></li>
+                <li class="divider"></li>
+                <li><a href="/submitting-patches.html">Submitting patches</a></li>
+                <li><a href="/builds.html">Source Code</a></li>
+                <li><a href="/coding-standards.html">Coding standards</a></li>
+                <li class="divider"></li>
+                <li><a href="/releases.html">Release Guidelines</a></li>
+                <li><a href="/bylaws.html">PMC Charter</a></li>
+                <li><a href="/volunteers.html">Volunteers</a></li>
+                <li><a href="https://git-wip-us.apache.org/repos/asf?p=struts.git">Source Repository</a></li>
+              </ul>
+            </li>
+            <li class="apache"><a href="http://www.apache.org/"><img src="/img/apache.png"></a></li>
+          </ul>
+        </div>
+      </div>
+    </div>
+  </nav>
+</header>
+
+
+<article class="container">
+  <section class="col-md-12">
+    <h2 id="processing-forms">Processing Forms</h2>
+
+<p>This tutorial assumes you’ve completed the <em>Coding Struts 2 Actons</em>  tutorial and have a working coding_actions project. The example code for this tutorial, form_processing, is available for checkout from the Struts 2 GitHub subversion repository: <a href="https://github.com/apache/struts-examples">https://github.com/apache/struts-examples</a>.</p>
+
+<blockquote>
+
+</blockquote>
+
+<p><strong>Introduction</strong></p>
+
+<p>In this tutorial we’ll explore using Struts 2 to do more involved processing of a form submission. We’ll cover how to use a Java model class to store the form input and how to create the Struts 2 form to match up with that model class.</p>
+
+<p>The code provided in this tutorial may be added to the <em>Coding Struts 2 Actions</em>  example or you can download this complete example from Google Code - <a href="http://code.google.com/p/struts2-examples/downloads/list">http://code.google.com/p/struts2-examples/downloads/list</a>.</p>
+
+<table>
+  <tbody>
+    <tr>
+      <td>The <a href="http://struts.apache.org/mail.html">Struts 2 user mailing list</a>^[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.</td>
+    </tr>
+  </tbody>
+</table>
+
+<table>
+  <tbody>
+    <tr>
+    </tr>
+  </tbody>
+</table>
+
+<p><strong>Forms and A Java Model Class</strong></p>
+
+<p>For this tutorial let’s say we need to provide a form that a user may submit to register for a prize drawing. Our business rules state the user must provide his/her first name, last name, email address, and age.</p>
+
+<p>To encapsulate this data, we’ll use a simple Java class that follows the basic Java Bean specifications (public set/get methods for each instance field). If you’re following along add this class to package org.apache.struts.register.model in the <em>Coding Struts 2 Actions</em>  example.</p>
+
+<p><strong>Person.java</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>public class Person
+{
+    private String firstName;
+    private String lastName;
+    private String email;
+    private int age;
+
+    public String getFirstName()
+    {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName)
+    {
+        this.firstName = firstName;
+    }
+
+    public String getLastName()
+    {
+        return lastName;
+    }
+
+    public void setLastName(String lastName)
+    {
+        this.lastName = lastName;
+    }
+
+    public String getEmail()
+    {
+        return email;
+    }
+
+    public void setEmail(String email)
+    {
+        this.email = email;
+    }
+
+    public int getAge()
+    {
+        return age;
+    }
+
+    public void setAge( int age)
+    {
+        this.age = age;
+    }
+
+
+    public String toString()
+    {
+        return "First Name: " + getFirstName() + " Last Name:  " + getLastName() + 
+        " Email:      " + getEmail() + " Age:      " + getAge() ;
+    }
+}
+
+</code></pre>
+</div>
+
+<p>Note a few points about the above class. There is a public set/get method for each instance field. The age attribute is of type integer. We’ve defined a public toString method that returns a String representing the state of the object. Since we haven’t specified a constructor, Java will provide a default constructor that will set all instance fields to their null values.</p>
+
+<p><strong>Form Structure</strong></p>
+
+<p>To collect the above information we’ll use a Struts 2 form. When creating this form the key concept we need to employ is to tie each form field to a specific instance field of an object of type Person. Let’s look over the form first and then discuss some key points. Create a view page named register.jsp (in WebContent (Ant version) or src/main/webapp (Maven version) )</p>
+
+<p><strong>register.jsp</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="cp">&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;</span>
+<span class="err">&lt;</span>%@ taglib prefix="s" uri="/struts-tags" %&gt;
+<span class="err">&lt;</span>%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+    pageEncoding="ISO-8859-1"%&gt;
+<span class="cp">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</span>
+<span class="nt">&lt;html</span> <span class="na">xmlns=</span><span class="s">"http://www.w3.org/1999/xhtml"</span><span class="nt">&gt;</span>
+<span class="nt">&lt;head&gt;</span>
+<span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">"Content-Type"</span> <span class="na">content=</span><span class="s">"text/html; charset=ISO-8859-1"</span> <span class="nt">/&gt;</span>
+<span class="nt">&lt;title&gt;</span>Register<span class="nt">&lt;/title&gt;</span>
+<span class="nt">&lt;/head&gt;</span>
+<span class="nt">&lt;body&gt;</span>
+<span class="nt">&lt;h3&gt;</span>Register for a prize by completing this form.<span class="nt">&lt;/h3&gt;</span>
+
+<span class="nt">&lt;s:form</span> <span class="na">action=</span><span class="s">"register"</span><span class="nt">&gt;</span>
+
+ 	  <span class="nt">&lt;s:textfield</span> <span class="na">name=</span><span class="s">"personBean.firstName"</span> <span class="na">label=</span><span class="s">"First name"</span> <span class="nt">/&gt;</span>
+ 	  <span class="nt">&lt;s:textfield</span>  <span class="na">name=</span><span class="s">"personBean.lastName"</span> <span class="na">label=</span><span class="s">"Last name"</span> <span class="nt">/&gt;</span>
+ 	  <span class="nt">&lt;s:textfield</span> <span class="na">name=</span><span class="s">"personBean.email"</span>  <span class="na">label =</span><span class="s">"Email"</span><span class="nt">/&gt;</span>  
+ 	  <span class="nt">&lt;s:textfield</span> <span class="na">name=</span><span class="s">"personBean.age"</span>  <span class="na">label=</span><span class="s">"Age"</span>  <span class="nt">/&gt;</span>
+ 	  
+   	  <span class="nt">&lt;s:submit/&gt;</span>
+   	  
+<span class="nt">&lt;/s:form&gt;</span>	
+ 
+<span class="nt">&lt;/body&gt;</span>
+<span class="nt">&lt;/html&gt;</span>
+
+</code></pre>
+</div>
+
+<p>Since we are using Struts 2 tags, at the top of the page we need the Struts tag library declaration.</p>
+
+<p>The Struts 2 form will submit to an action named register. We’ll need to define that action in our struts.xml file.</p>
+
+<p>Note the four Struts 2 textfield tags. Each tag has a name value that includes an attribute of the Person class (e.g. firstName). The name attribute’s value also has a reference to an object called personBean. This object is of type Person. When we create the Action class that handles this form submission, we’ll have to specify that object in that Action class (see below).</p>
+
+<p>The complete name value, personBean.firstName, instructs Struts 2 to use the input value for that textfield as the argument to the personBean object’s setFirstName method. So if the user types “Bruce” in the textfield that has the label “First name”, the personBean’s firstName instance field will have a value of “Bruce”.</p>
+
+<p>Note we have a Struts 2 textfield for each instance field of the class Person. Remember that Person class’s age attribute is of type integer. All form field input values are Strings. Struts 2 will automatically convert the String value (“25”) the user entered for the age form field to 25 when calling the setAge method of object personBean.</p>
+
+<p><strong>Creating the Action Class To Handle the Form Submission</strong></p>
+
+<p>When the user clicks on the submit button of the above form, the action “register” and the form data will be sent to the Struts 2 framework. We need an Action class to process this form. If you recall from the tutorial <em>Coding Struts 2 Actions</em>  our Action class should extends the Struts 2 ActionSupport class.</p>
+
+<p>Here is the Action class used for this example. Place it in package org.apache.struts.register.action.</p>
+
+<p><strong>Register.java Struts 2 Action Class</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>package org.apache.struts.register.action;
+
+import org.apache.struts.register.model.Person;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+public class Register extends ActionSupport {
+	
+	private static final long serialVersionUID = 1L;
+	
+	private Person personBean;
+	
+
+	@Override
+	public String execute() throws Exception {
+		
+		//call Service class to store personBean's state in database
+		
+		return SUCCESS;
+		
+	}
+	
+	public Person getPersonBean() {
+		
+		return personBean;
+		
+	}
+	
+	public void setPersonBean(Person person) {
+		
+		personBean = person;
+		
+	}
+
+}
+
+</code></pre>
+</div>
+
+<p>In the Register class note that we’ve declared an attribute named personBean of type Person and there is a public get and set method for this object.</p>
+
+<p>The Register class also overrides the execute method. The execute method is the one we will specify in the struts.xml to be called in response to the register action. In this example, the execute method just returns the String constant SUCCESS (inherited from ActionSupport class). But in a real application, within the execute method we would call upon other classes (Service objects) to perform the business processing of the form, such as storing the user’s input into a data repository.</p>
+
+<p>The personBean object of type Person declared in the Register Action class matches the personBean name we used in the form’s textfields. When the form is submitted, the Struts 2 framework will inspect the Action class and look for an object named personBean. It will create that object using the Person class’s default constructor. Then for each form field that has a name value of personBean.someAttribute (e.g personBean.firstName) it will call the personBean’s public set method for that attribute and pass it the form field’s value (the user input). This all happens before the execute method occurs.</p>
+
+<p>When Struts 2 runs the execute method of class Register, the personBean object in class Register now has values for its instance fields that are equal to the values the user entered into the corresponding form fields.</p>
+
+<p>By using a Java model class to encapsulate the data provided by the form we don’t have to have a separate attribute (with public set/get methods) in the Action class (Register) for each form field.</p>
+
+<p><strong>Handle SUCCESS Being Returned By Execute Method</strong></p>
+
+<p>When SUCCESS is returned by the execute method we want to display a simple thank you page that shows the user’s registration. Add the thankyou.jsp below to either WebContent (Ant) or src/main/webapp (Maven).</p>
+
+<p><strong>thankyou.jsp</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="cp">&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;</span>
+<span class="err">&lt;</span>%@ taglib prefix="s" uri="/struts-tags" %&gt;
+<span class="err">&lt;</span>%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+    pageEncoding="ISO-8859-1"%&gt;
+<span class="cp">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</span>
+<span class="nt">&lt;html</span> <span class="na">xmlns=</span><span class="s">"http://www.w3.org/1999/xhtml"</span><span class="nt">&gt;</span>
+<span class="nt">&lt;head&gt;</span>
+<span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">"Content-Type"</span> <span class="na">content=</span><span class="s">"text/html; charset=ISO-8859-1"</span> <span class="nt">/&gt;</span>
+<span class="nt">&lt;title&gt;</span>Registration Successful<span class="nt">&lt;/title&gt;</span>
+<span class="nt">&lt;/head&gt;</span>
+<span class="nt">&lt;body&gt;</span>
+<span class="nt">&lt;h3&gt;</span>Thank you for registering for a prize.<span class="nt">&lt;/h3&gt;</span>
+
+<span class="nt">&lt;p&gt;</span>Your registration information: <span class="nt">&lt;s:property</span> <span class="na">value=</span><span class="s">"personBean"</span> <span class="nt">/&gt;</span> <span class="nt">&lt;/p&gt;</span>
+
+<span class="nt">&lt;p&gt;&lt;a</span> <span class="na">href=</span><span class="s">"&lt;s:url action='index' /&gt;"</span> <span class="nt">&gt;</span>Return to home page<span class="nt">&lt;/a&gt;</span>.<span class="nt">&lt;/p&gt;</span>
+
+<span class="nt">&lt;/body&gt;</span>
+<span class="nt">&lt;/html&gt;</span>
+
+
+
+</code></pre>
+</div>
+
+<p>If you don’t recall how the Struts 2 property and url tags work consult the <a href="#PAGE_14811875">Using Struts 2 Tags</a> tutorial.</p>
+
+<p><strong>Create action Node In struts.xml</strong></p>
+
+<p>To specify the relationship between the form submission page, the Struts 2 Action class, and the success view page we need to add an action node to struts.xml. Add this action node to struts.xml (src folder (Ant version) or src/main/resources (Maven version) ) after the hello action and before the closing package node.</p>
+
+<p><strong>action node for struts.xml</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;action name="register" class="org.apache.struts.register.action.Register" method="execute"&gt;
+  &lt;result name="success"&gt;/thankyou.jsp&lt;/result&gt;
+&lt;/action&gt;
+
+
+</code></pre>
+</div>
+
+<p>The above action tells Struts 2 that when the register action is provided to call method execute of class Register. If that method returns result “success” return to the browser the thankyou.jsp.</p>
+
+<p>Note that we don’t need to tell Struts 2 anything about processing the form. The transfer of the form field input values to the personBean object will happen automatically provided we’ve followed the convention of naming our form fields to match personBean.attributeName (e.g. personBean.lastName).</p>
+
+<p><strong>Create A Link To register.jsp</strong></p>
+
+<p>So that the user can find the registration page, add this link to index.jsp</p>
+
+<p><strong>Link to register.jsp</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;p&gt;&lt;a href="register.jsp"&gt;Please register&lt;/a&gt; for our prize drawing.&lt;/p&gt;
+
+</code></pre>
+</div>
+
+<p><strong>Run The Example</strong></p>
+
+<p>If everything is correct, you should be able to create the war file, deploy the war file to your Servlet container, and open this URL in your web browser: <a href="http://localhost:8080/form_processing/index.action">http://localhost:8080/form_processing/index.action</a>. On that page should be a link to register. Click on that link and you should see the register.jsp page.</p>
+
+<p><img src="attachments/att14974999_registerjsp.png" alt="registerjsp.png" /></p>
+
+<p>Fill out the form and click the submit button. You should then see the thankyou.jsp page.</p>
+
+<p><img src="attachments/att14975000_thanyoujsp.png" alt="thanyoujsp.png" /></p>
+
+  </section>
+</article>
+
+
+<footer class="container">
+  <div class="col-md-12">
+    Copyright &copy; 2000-2016 <a href="http://www.apache.org/">The Apache Software Foundation </a>.
+    All Rights Reserved.
+  </div>
+  <div class="col-md-12">
+    Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project logos are
+    trademarks of The Apache Software Foundation.
+  </div>
+  <div class="col-md-12">Logo and website design donated by <a href="https://softwaremill.com/">SoftwareMill</a>.</div>
+</footer>
+
+<script>!function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (!d.getElementById(id)) {
+    js = d.createElement(s);
+    js.id = id;
+    js.src = "//platform.twitter.com/widgets.js";
+    fjs.parentNode.insertBefore(js, fjs);
+  }
+}(document, "script", "twitter-wjs");</script>
+<script src="https://apis.google.com/js/platform.js" async="async" defer="defer"></script>
+
+<div id="fb-root"></div>
+
+<script>(function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (d.getElementById(id)) return;
+  js = d.createElement(s);
+  js.id = id;
+  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
+  fjs.parentNode.insertBefore(js, fjs);
+}(document, 'script', 'facebook-jssdk'));</script>
+
+
+<script>
+$(function() {
+  return $("h2, h3, h4, h5, h6").each(function(i, el) {
+    var $el, icon, id;
+    $el = $(el);
+    id = $el.attr('id');
+    icon = '<i class="fa fa-link"></i>';
+    if (id) {
+      return $el.prepend($("<a />").addClass("header-link").attr("href", "#" + id).html(icon));
+    }
+  });
+});
+</script>
+
+</body>
+</html>

Added: websites/production/struts/content/getting-started/spring.html
==============================================================================
--- websites/production/struts/content/getting-started/spring.html (added)
+++ websites/production/struts/content/getting-started/spring.html Fri Mar 31 05:44:39 2017
@@ -0,0 +1,440 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8"/>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+  <meta name="Date-Revision-yyyymmdd" content="20140918"/>
+  <meta http-equiv="Content-Language" content="en"/>
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+
+  <title>Spring</title>
+
+  <link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic,600italic,700italic" rel="stylesheet" type="text/css">
+  <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
+  <link href="/css/main.css" rel="stylesheet">
+  <link href="/css/custom.css" rel="stylesheet">
+
+  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+  <script type="text/javascript" src="/bootstrap/js/bootstrap.js"></script>
+  <script type="text/javascript" src="/js/community.js"></script>
+</head>
+<body>
+
+<a href="http://github.com/apache/struts" class="github-ribbon">
+  <img style="position: absolute; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub">
+</a>
+
+<header>
+  <nav>
+    <div role="navigation" class="navbar navbar-default navbar-fixed-top">
+      <div class="container">
+        <div class="navbar-header">
+          <button type="button" data-toggle="collapse" data-target="#struts-menu" class="navbar-toggle">
+            Menu
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+          <a href="/index.html" class="navbar-brand logo"><img src="/img/struts-logo.svg"></a>
+        </div>
+        <div id="struts-menu" class="navbar-collapse collapse">
+          <ul class="nav navbar-nav">
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Home<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/index.html">Welcome</a></li>
+                <li><a href="/downloads.html">Downloads</a></li>
+                <li><a href="/announce.html">Announcements</a></li>
+                <li><a href="http://www.apache.org/licenses/">License</a></li>
+                <li><a href="http://apache.org/foundation/thanks.html">Thanks!</a></li>
+                <li><a href="http://apache.org/foundation/sponsorship.html">Sponsorship</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Support<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/mail.html">User Mailing List</a></li>
+                <li><a href="https://issues.apache.org/jira/browse/WW">Issue Tracker</a></li>
+                <li><a href="/security.html">Reporting Security Issues</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/project-info.html">Project info</a></li>
+                <li><a href="/maven/struts2-core/dependencies.html">Struts Core dependencies</a></li>
+                <li><a href="/maven/struts2-plugins/modules.html">Plugin dependencies</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Documentation<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/birdseye.html">Birds Eye</a></li>
+                <li><a href="/primer.html">Key Technologies</a></li>
+                <li><a href="/kickstart.html">Kickstart FAQ</a></li>
+                <li><a href="https://cwiki.apache.org/confluence/display/WW/Home">Wiki</a></li>
+                <li class="divider"></li>
+                <li><a href="/docs/home.html">Getting started</a></li>
+                <li><a href="/docs/tutorials.html">Tutorials</a></li>
+                <li><a href="/docs/faqs.html">FAQs</a></li>
+                <li><a href="/docs/guides.html">Guides</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/struts2-core/apidocs/index.html">Struts Core API</a></li>
+                <li><a href="/docs/plugins.html">Plugin APIs</a></li>
+                <li><a href="/docs/tag-reference.html">Tag reference</a></li>
+                <li><a href="http://cwiki.apache.org/S2PLUGINS/home.html">Plugin registry</a></li>
+                <li class="divider"></li>
+                <li><a href="/getting-started/getting-started.html">Getting Started (WIP)</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Contributing<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/youatstruts.html">You at Struts</a></li>
+                <li><a href="/helping.html">How to Help FAQ</a></li>
+                <li><a href="/dev-mail.html">Development Lists</a></li>
+                <li class="divider"></li>
+                <li><a href="/submitting-patches.html">Submitting patches</a></li>
+                <li><a href="/builds.html">Source Code</a></li>
+                <li><a href="/coding-standards.html">Coding standards</a></li>
+                <li class="divider"></li>
+                <li><a href="/releases.html">Release Guidelines</a></li>
+                <li><a href="/bylaws.html">PMC Charter</a></li>
+                <li><a href="/volunteers.html">Volunteers</a></li>
+                <li><a href="https://git-wip-us.apache.org/repos/asf?p=struts.git">Source Repository</a></li>
+              </ul>
+            </li>
+            <li class="apache"><a href="http://www.apache.org/"><img src="/img/apache.png"></a></li>
+          </ul>
+        </div>
+      </div>
+    </div>
+  </nav>
+</header>
+
+
+<article class="container">
+  <section class="col-md-12">
+    <h2 id="spring-and-struts-2">Spring and Struts 2</h2>
+
+<p>The example code for this tutorial, spring_struts, is available for checkout at <a href="https://github.com/apache/struts-examples">https://github.com/apache/struts-examples</a></p>
+
+<blockquote>
+
+</blockquote>
+
+<p>#####Introduction#####</p>
+
+<p>In the execute method of many Struts 2 ActionSupport classes are statements that create objects and then have those objects execute methods that perform needed tasks. Whenever one class creates an object of another class that introduces a dependency between the two classes. The Spring framework makes it easier for the application developer to manage these dependencies and helps make the application more flexible and maintainable. This tutorial will show you how to use Struts 2 and Spring together to manage the dependencies between your ActionSupport classes and other classes in your application.</p>
+
+<blockquote>
+
+</blockquote>
+
+<blockquote>
+
+</blockquote>
+
+<blockquote>
+  <p>This tutorial assumes you understand how to use the Spring framework to manage dependencies between classes. You can learn more about Spring by reading the documentation at <a href="http://www.springsource.org/documentation">http://www.springsource.org/documentation</a></p>
+</blockquote>
+
+<blockquote>
+
+</blockquote>
+
+<table>
+  <tbody>
+    <tr>
+    </tr>
+  </tbody>
+</table>
+
+<table>
+  <tbody>
+    <tr>
+      <td>The <a href="http://struts.apache.org/mail.html">Struts 2 user mailing list</a>^[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.</td>
+    </tr>
+  </tbody>
+</table>
+
+<table>
+  <tbody>
+    <tr>
+    </tr>
+  </tbody>
+</table>
+
+<p>If you examine the example application for the <a href="#PAGE_23337450">Struts 2 Themes</a> tutorial you’ll see this code in the EditAction ActionSupport class</p>
+
+<p><strong>EditAction Class Hard-Coded Dependency</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>private EditService editService = new EditServiceInMemory();
+
+
+</code></pre>
+</div>
+
+<p>The above statement hard-codes a dependency between the EditAction class and the EditServiceInMemory class. This is poor design for two reasons.</p>
+
+<ol>
+  <li>
+    <p>If I need to replace the EditServiceInMemory with another class that implements the EditService interface I’ll have to hunt down and replace all statements where I hard-coded the dependency.</p>
+  </li>
+  <li>
+    <p>I cannot test EditAction without using the EditServiceInMemory class. I cannot isolate EditAction by using a stub implementation of EditService when writing my test case because the use of EditServiceInMemory is hard-coded.</p>
+  </li>
+</ol>
+
+<p>Spring provides a mechanism to manage dependencies by injecting them at run time. Struts 2 ActionSupport classes—like any other Java class—can be injected with a dependent object by the Spring framework. So instead of having the above code, I would have this statement in EditAction.</p>
+
+<p><strong>EditAction Class No Hard-Coded Dependency</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>    private EditService editService ;
+
+
+</code></pre>
+</div>
+
+<p>At run time the Spring framework will provide an object of a class that implements the EditService interface.</p>
+
+<p>#####Struts 2 Spring Plugin#####</p>
+
+<p>Struts 2 provides a plugin that enables Spring to inject into the ActionSupport classes any dependent objects you’ve specified in the Spring configuration file. Consult <em>Spring Plugin documentation</em>  for more information about how the plugin works.</p>
+
+<p>For a Maven application you’ll need to add a dependency to the struts2-spring-plugin jar (see the Maven example application for this tutorial). The plugin’s pom.xml includes transitive dependencies to the Spring jar files.</p>
+
+<table>
+  <tbody>
+    <tr>
+      <td>The current version (2.3.15) of the Struts 2 Spring plugin has transitive dependencies to the Spring 3.0.5 version. If you want to use the latest version of Spring, then you should exclude the transitive dependencies in your pom.xml for the Struts 2 Spring plugin and then declare dependency nodes to the current version of the Spring jar files. If you are using Ant and explicitly including the jar files in your application, then just include the latest version of the Spring jar files.</td>
+    </tr>
+  </tbody>
+</table>
+
+<table>
+  <tbody>
+    <tr>
+    </tr>
+  </tbody>
+</table>
+
+<p>In your ActionSupport class you must have a set method for the dependent object that follows standard Java bean naming conventions. If you examine the EditAction class for this tutorial’s application you’ll see this set method.</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>public void setEditService(EditService editService) {
+		
+   this.editService = editService;
+		
+}
+
+
+</code></pre>
+</div>
+
+<p>Spring will use that set method to provide an object of type EditService to the EditAction class at run time.</p>
+
+<p>To make our application “Spring aware” we need to add this line to web.xml.</p>
+
+<p><strong>Spring Listener In web.xml</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;listener&gt;
+	&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
+&lt;/listener&gt;
+
+
+</code></pre>
+</div>
+
+<p>The above code will activate the Spring framework when the application is started up by the Servlet container. By default Spring will look for a configuration file name applicationContext.xml in WEB-INF (consult the Spring documentation for how you can change where Spring looks and what the configuration file name is).</p>
+
+<p>#####Spring Configuration File#####</p>
+
+<p>In the Spring configuration file we create a bean node for those objects we want Spring to create an instance of and inject into our ActionSupport class. In the example application is this applicationContext.xml.</p>
+
+<p><strong>Spring Configuration File</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="cp">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
+<span class="nt">&lt;beans</span> <span class="na">xmlns=</span><span class="s">"http://www.springframework.org/schema/beans"</span>
+       <span class="na">xmlns:xsi=</span><span class="s">"http://www.w3.org/2001/XMLSchema-instance"</span>
+       <span class="na">xsi:schemaLocation=</span><span class="s">"</span>
+            <span class="err">http://www.springframework.org/schema/beans</span>
+            <span class="err">http://www.springframework.org/schema/beans/spring-beans.xsd"</span><span class="nt">&gt;</span>
+
+<span class="nt">&lt;bean</span> <span class="na">id=</span><span class="s">"editService"</span> <span class="na">class=</span><span class="s">"org.apache.struts.edit.service.EditServiceInMemory"</span> <span class="nt">/&gt;</span>
+
+<span class="nt">&lt;/beans&gt;</span>
+
+
+</code></pre>
+</div>
+
+<p>Note the id value above. By default the Spring plugin works with Spring to autowire the dependencies of the ActionClass by “name.” Spring will create an object of class EditServiceMemory and provide that object to any ActionSupport class that has a setEditService method with an argument of type EditService. Consult the <em>Spring Plugin</em>  documentation for how to change the default autowire method.</p>
+
+<table>
+  <tbody>
+    <tr>
+      <td>The editService bean created by Spring will have a scope of singleton since that is the default scope. Consult section 3.5 of the <a href="http://www.springsource.org/documentation">Spring documentation</a>^[http://www.springsource.org/documentation] for how to configure the bean definition to use a different scope (e.g. request or session).</td>
+    </tr>
+  </tbody>
+</table>
+
+<table>
+  <tbody>
+    <tr>
+    </tr>
+  </tbody>
+</table>
+
+<p>#####Alternative - Have Spring Manage Creation Of ActionSupport Class#####</p>
+
+<p>Using the above methodology, the Struts 2 framework will still manage the creation of the ActionSupport class. If you prefer you can configure the application so that Spring will create the ActionSupport class also. To support this technique you need to add a bean node to the Spring configuration file for the ActionSupport class.</p>
+
+<p><strong>Spring Configuration For ActionSupport Class Managed By Spring</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="cp">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span>
+<span class="nt">&lt;beans</span> <span class="na">xmlns=</span><span class="s">"http://www.springframework.org/schema/beans"</span>
+       <span class="na">xmlns:xsi=</span><span class="s">"http://www.w3.org/2001/XMLSchema-instance"</span>
+       <span class="na">xsi:schemaLocation=</span><span class="s">"</span>
+            <span class="err">http://www.springframework.org/schema/beans</span>
+            <span class="err">http://www.springframework.org/schema/beans/spring-beans.xsd"</span><span class="nt">&gt;</span>
+            
+
+<span class="nt">&lt;bean</span> <span class="na">id=</span><span class="s">"editService"</span> <span class="na">class=</span><span class="s">"org.apache.struts.edit.service.EditServiceInMemory"</span> <span class="nt">/&gt;</span>
+
+<span class="nt">&lt;bean</span> <span class="na">id=</span><span class="s">"editAction"</span> <span class="na">class=</span><span class="s">"org.apache.struts.edit.action.EditAction"</span> <span class="na">scope=</span><span class="s">"prototype"</span><span class="nt">&gt;</span>
+
+	<span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">"editService"</span> <span class="na">ref=</span><span class="s">"editService"</span> <span class="nt">/&gt;</span>
+	
+<span class="nt">&lt;/bean&gt;</span>
+
+<span class="nt">&lt;/beans&gt;</span>
+
+
+</code></pre>
+</div>
+
+<p>Note in the above that there is an</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>editAction
+</code></pre>
+</div>
+<p> bean and its</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>editService
+</code></pre>
+</div>
+<p> property is set to the</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>editService
+</code></pre>
+</div>
+<p> bean. Since we are having Spring manage the</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>EditAction
+</code></pre>
+</div>
+<p> class we must specify any properties of</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>EditAction
+</code></pre>
+</div>
+<p> that we want Spring to inject. Please remember that actions must be created on each request, they cannot be </p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>singletons
+</code></pre>
+</div>
+<ul>
+  <li>this is the default </li>
+</ul>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>scope
+</code></pre>
+</div>
+<p>that’s why it must be changed to </p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>prototype
+</code></pre>
+</div>
+<p>.</p>
+
+<p>In the</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
+</code></pre>
+</div>
+<p> configuration file you must specify the Spring id value for the class attribute of the action node. This tells Struts to get a bean with that id value from Spring for the Action class.</p>
+
+<p><strong>Struts Configuration For Spring Managed ActionSupport Class</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;action name="edit" class="editAction" method="input"&gt;
+	&lt;result name="input"&gt;/edit.jsp&lt;/result&gt;
+&lt;/action&gt;
+
+
+</code></pre>
+</div>
+
+<p>#####Summary#####</p>
+
+<p>In this tutorial we reviewed how to use the Struts 2 Spring plugin to integrate Spring and Struts. By using the Struts 2 Spring plugin you can have Spring manage the dependencies of your ActionSupport classes. Of course you can also take advantage of the many other benefits (AOP, Spring JDBC) that the Spring framework provides.</p>
+
+  </section>
+</article>
+
+
+<footer class="container">
+  <div class="col-md-12">
+    Copyright &copy; 2000-2016 <a href="http://www.apache.org/">The Apache Software Foundation </a>.
+    All Rights Reserved.
+  </div>
+  <div class="col-md-12">
+    Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project logos are
+    trademarks of The Apache Software Foundation.
+  </div>
+  <div class="col-md-12">Logo and website design donated by <a href="https://softwaremill.com/">SoftwareMill</a>.</div>
+</footer>
+
+<script>!function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (!d.getElementById(id)) {
+    js = d.createElement(s);
+    js.id = id;
+    js.src = "//platform.twitter.com/widgets.js";
+    fjs.parentNode.insertBefore(js, fjs);
+  }
+}(document, "script", "twitter-wjs");</script>
+<script src="https://apis.google.com/js/platform.js" async="async" defer="defer"></script>
+
+<div id="fb-root"></div>
+
+<script>(function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (d.getElementById(id)) return;
+  js = d.createElement(s);
+  js.id = id;
+  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
+  fjs.parentNode.insertBefore(js, fjs);
+}(document, 'script', 'facebook-jssdk'));</script>
+
+
+<script>
+$(function() {
+  return $("h2, h3, h4, h5, h6").each(function(i, el) {
+    var $el, icon, id;
+    $el = $(el);
+    id = $el.attr('id');
+    icon = '<i class="fa fa-link"></i>';
+    if (id) {
+      return $el.prepend($("<a />").addClass("header-link").attr("href", "#" + id).html(icon));
+    }
+  });
+});
+</script>
+
+</body>
+</html>

Added: websites/production/struts/content/getting-started/themes.html
==============================================================================
--- websites/production/struts/content/getting-started/themes.html (added)
+++ websites/production/struts/content/getting-started/themes.html Fri Mar 31 05:44:39 2017
@@ -0,0 +1,367 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8"/>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+  <meta name="Date-Revision-yyyymmdd" content="20140918"/>
+  <meta http-equiv="Content-Language" content="en"/>
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+
+  <title>Themes</title>
+
+  <link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic,600italic,700italic" rel="stylesheet" type="text/css">
+  <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
+  <link href="/css/main.css" rel="stylesheet">
+  <link href="/css/custom.css" rel="stylesheet">
+
+  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+  <script type="text/javascript" src="/bootstrap/js/bootstrap.js"></script>
+  <script type="text/javascript" src="/js/community.js"></script>
+</head>
+<body>
+
+<a href="http://github.com/apache/struts" class="github-ribbon">
+  <img style="position: absolute; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub">
+</a>
+
+<header>
+  <nav>
+    <div role="navigation" class="navbar navbar-default navbar-fixed-top">
+      <div class="container">
+        <div class="navbar-header">
+          <button type="button" data-toggle="collapse" data-target="#struts-menu" class="navbar-toggle">
+            Menu
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+          <a href="/index.html" class="navbar-brand logo"><img src="/img/struts-logo.svg"></a>
+        </div>
+        <div id="struts-menu" class="navbar-collapse collapse">
+          <ul class="nav navbar-nav">
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Home<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/index.html">Welcome</a></li>
+                <li><a href="/downloads.html">Downloads</a></li>
+                <li><a href="/announce.html">Announcements</a></li>
+                <li><a href="http://www.apache.org/licenses/">License</a></li>
+                <li><a href="http://apache.org/foundation/thanks.html">Thanks!</a></li>
+                <li><a href="http://apache.org/foundation/sponsorship.html">Sponsorship</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Support<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/mail.html">User Mailing List</a></li>
+                <li><a href="https://issues.apache.org/jira/browse/WW">Issue Tracker</a></li>
+                <li><a href="/security.html">Reporting Security Issues</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/project-info.html">Project info</a></li>
+                <li><a href="/maven/struts2-core/dependencies.html">Struts Core dependencies</a></li>
+                <li><a href="/maven/struts2-plugins/modules.html">Plugin dependencies</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Documentation<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/birdseye.html">Birds Eye</a></li>
+                <li><a href="/primer.html">Key Technologies</a></li>
+                <li><a href="/kickstart.html">Kickstart FAQ</a></li>
+                <li><a href="https://cwiki.apache.org/confluence/display/WW/Home">Wiki</a></li>
+                <li class="divider"></li>
+                <li><a href="/docs/home.html">Getting started</a></li>
+                <li><a href="/docs/tutorials.html">Tutorials</a></li>
+                <li><a href="/docs/faqs.html">FAQs</a></li>
+                <li><a href="/docs/guides.html">Guides</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/struts2-core/apidocs/index.html">Struts Core API</a></li>
+                <li><a href="/docs/plugins.html">Plugin APIs</a></li>
+                <li><a href="/docs/tag-reference.html">Tag reference</a></li>
+                <li><a href="http://cwiki.apache.org/S2PLUGINS/home.html">Plugin registry</a></li>
+                <li class="divider"></li>
+                <li><a href="/getting-started/getting-started.html">Getting Started (WIP)</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Contributing<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/youatstruts.html">You at Struts</a></li>
+                <li><a href="/helping.html">How to Help FAQ</a></li>
+                <li><a href="/dev-mail.html">Development Lists</a></li>
+                <li class="divider"></li>
+                <li><a href="/submitting-patches.html">Submitting patches</a></li>
+                <li><a href="/builds.html">Source Code</a></li>
+                <li><a href="/coding-standards.html">Coding standards</a></li>
+                <li class="divider"></li>
+                <li><a href="/releases.html">Release Guidelines</a></li>
+                <li><a href="/bylaws.html">PMC Charter</a></li>
+                <li><a href="/volunteers.html">Volunteers</a></li>
+                <li><a href="https://git-wip-us.apache.org/repos/asf?p=struts.git">Source Repository</a></li>
+              </ul>
+            </li>
+            <li class="apache"><a href="http://www.apache.org/"><img src="/img/apache.png"></a></li>
+          </ul>
+        </div>
+      </div>
+    </div>
+  </nav>
+</header>
+
+
+<article class="container">
+  <section class="col-md-12">
+    <h2 id="themes">Themes</h2>
+
+<p>The example code for this tutorial, themes, is available for checkout at <a href="https://github.com/apache/struts-examples">https://github.com/apache/struts-examples</a></p>
+
+<blockquote>
+
+</blockquote>
+
+<p>#####Introduction#####</p>
+
+<p>When you use a Struts 2 tag such as s:select in your web page, the Struts 2 framework generates HTML that styles the appearance and controls the layout of the select control. The style and layout is determined by which Struts 2 theme is set for the tag. Struts 2 comes with three built-in themes: simple, xhtml, and css_xhtml. If you don’t specify a theme, then Struts 2 will use the xhtml theme by default.</p>
+
+<table>
+  <tbody>
+    <tr>
+      <td>The <a href="http://struts.apache.org/mail.html">Struts 2 user mailing list</a>^[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.</td>
+    </tr>
+  </tbody>
+</table>
+
+<table>
+  <tbody>
+    <tr>
+    </tr>
+  </tbody>
+</table>
+
+<p>For example, this Struts 2 select tag:</p>
+
+<p><strong>Struts 2 Select Tag</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;s:select key="personBean.sport" list="sports" /&gt;
+
+</code></pre>
+</div>
+
+<p>generates this HTML markup:</p>
+
+<p><strong>HTML Created By Struts 2 Select Tag</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;tr&gt;
+&lt;td class="tdLabel"&gt;
+&lt;label for="save_personBean_sport" class="label"&gt;Favorite sport:&lt;/label&gt;
+&lt;/td&gt;
+&lt;td&gt;
+&lt;select name="personBean.sport" id="save_personBean_sport"&gt;
+    &lt;option value="football"&gt;football&lt;/option&gt;
+    &lt;option value="baseball"&gt;baseball&lt;/option&gt;
+    &lt;option value="basketball" selected="selected"&gt;basketball&lt;/option&gt;
+&lt;/select&gt;
+&lt;/td&gt;
+&lt;/tr&gt;
+
+</code></pre>
+</div>
+
+<p>Notice how the HTML generated uses table tags to control the layout of the label and select HTML. There is also a class, tdLabel, applied to the table column where the label tag is rendered. Since no theme was specified for the Struts 2 select tag the default xhmtl theme was used.</p>
+
+<p>#####Specifying The Theme Struts 2 Should Use#####</p>
+
+<p>The Struts 2 tags have a theme attribute you can use to specify which Struts 2 theme should be used when creating the HTML for that tag. The values for the theme attribute are simple, xhtml, css_xhtml, and ajax. To learn more about these themes visit <em>Themes and Templates Documentation</em> . This tutorial will review the xhtml, css_xhtml, and the simple themes. The ajax theme is a special theme used for ajax operations (see <em>Ajax Theme in the documentation</em> ).</p>
+
+<p>You can specify the theme on a per Struts 2 tag basis or you can use one of the following methods to specify what theme Struts 2 should use:</p>
+
+<ol>
+  <li>
+    <p>The theme attribute on the specific tag</p>
+  </li>
+  <li>
+    <p>The theme attribute on a tag’s surrounding form tag</p>
+  </li>
+  <li>
+    <p>The page-scoped attribute named “theme”</p>
+  </li>
+  <li>
+    <p>The request-scoped attribute named “theme”</p>
+  </li>
+  <li>
+    <p>The session-scoped attribute named “theme”</p>
+  </li>
+  <li>
+    <p>The application-scoped attribute named “theme”</p>
+  </li>
+  <li>
+    <p>The struts.ui.theme property in struts.properties (defaults to xhtml)</p>
+  </li>
+</ol>
+
+<p>Consult <em>Selecting Themes</em>  for how to set the theme using the above approaches.</p>
+
+<p>In the example application, examine edit.jsp. The theme attribute of the form tag is set to xhtml. Run the application (see the readme.txt file) and view the source for edit.jsp after it is rendered in your browser. You should see the form HTML tags layout controlled by table tags.</p>
+
+<p>Change the theme to simple for the form’s theme attribute and redeploy the application. Examine the source for edit.jsp after it is rendered in the browser. You should see that there are no table tags controlling the layout and also there are no label tags for the text fields.</p>
+
+<p>Change the theme to css_xhtml for the form’s theme attribute and redeploy the application. Examine the source for edit.jsp after it is rendered in the browser. The layout of the form tags is now controlled by div tags and the label tags are back.</p>
+
+<p>#####Specifying The CSS Used By The Struts 2 Tag#####</p>
+
+<p>Change the theme attribute for the form tag back to xhtml. Notice when you view the source of edit.jsp after it is rendered in the browser that there is a class named tdLabel applied to the table column that contains the label. This CSS class controls the position of the label in the table column. The tdLabel style is defined in /themes/struts/xhtml/styles.css. The link to this style sheet was included in edit.jsp’s head section when you add the s:head tag to edit.jsp.</p>
+
+<p>Load this style sheet in your browser (in the example application the link is <a href="http://localhost:8080/themes/struts/xhtml/styles.css">http://localhost:8080/themes/struts/xhtml/styles.css</a> if your Servlet container is running on localhost, port 8080). You’ll see the following:</p>
+
+<p><strong>styles.css</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>.label {font-style:italic; }
+.errorLabel {font-style:italic; color:red; }
+.errorMessage {font-weight:bold; color:red; }
+.checkboxLabel {}
+.checkboxErrorLabel {color:red; }
+.required {color:red;}
+.tdLabel {text-align:right; vertical-align:top; }
+
+</code></pre>
+</div>
+
+<p>So the .label selector renders the label tag’s text in italic. The .tdLabel tag specifies that the text should align to the right and top of the table column.</p>
+
+<p>You can override the above selectors by including the same selectors in your page’s head section. For example add the following to the head section of edit.jsp.</p>
+
+<p><strong>Override Label Style</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;style type="text/css"&gt;
+  .label {color:blue; font-style:normal; font-weight:bold}
+&lt;/style&gt;
+
+</code></pre>
+</div>
+
+<p>Now the label tag will render the text in blue, bold, normal (not italics) style.</p>
+
+<p>#####Creating And Applying Your Own Themes For Struts 2 Tags#####</p>
+
+<p>The theme templates (simple, xhtml, css_xhtml) can be found in the Struts 2 core jar file. If you expand (extract the files) the Struts 2 core jar file you’ll find folders named template.css_xhtml, template.simple, and template.xhtml. Those folders contain the templates for the three default Struts 2 themes. In each folder is a file for each Struts 2 tag. For example if you expand the template.xhtml folder you’ll see the select.ftl file.</p>
+
+<p>The Struts 2 framework uses the FreeMarker template engine to generate the HTML for the Struts 2 tags. That’s why the file extension is “.ftl”. You can learn more about FreeMarker by visiting <a href="http://freemarker.sourceforge.net/">http://freemarker.sourceforge.net/</a>.</p>
+
+<p>Also in the template.xhmtl folder is the styles.css file. This is the styles.css file that your application will use if it uses the xhtml theme.</p>
+
+<p>Let’s say we wanted to create our own theme that will change how the Struts 2 checkboxlist tag displays the checkboxes and their labels.</p>
+
+<p>In the example application I’ve extended the default XHMTL theme (see file theme.properties under src/main/resources/template/KUTheme).  The checkboxlist.ftl theme that is part of the XHTML theme only includes a space between each label and the next checkbox (see checkboxlist.ftl in the template/simple folder in Struts 2 core). That is why all the checkboxes are displayed across the width of the browser window. For my custom checkboxlist theme I want to have a break tag after each label tag so that each checkbox and its label will be on their own line.</p>
+
+<p>In the example application there is a folder named src/main/resources/template/KUTheme. In that folder is a checkboxlist.ftl, the contents of which I originally copied from the checkboxlist.ftl that is in the templates.xhtml folder from the struts 2 core jar.</p>
+
+<p>I then modified the checkboxlist.ftl in the KUTheme folder to be:</p>
+
+<p><strong>Modified checkboxlist.ftl</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>&lt;#include "/${parameters.templateDir}/${parameters.expandTheme}/controlheader.ftl" /&gt;
+
+&lt;#include "/${parameters.templateDir}/KUTheme_simple/checkboxlist.ftl" /&gt;
+
+&lt;#include "/${parameters.templateDir}/${parameters.expandTheme}/controlfooter.ftl" /&gt;&lt;#nt/&gt;
+
+</code></pre>
+</div>
+
+<p>Be sure to note the change to the second line—using KUTheme_simple in the path.</p>
+
+<p>Then in the example application I created a KUTheme_simple folder under</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>src/main/resources/template
+</code></pre>
+</div>
+<p>(optionally you can place it under</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>webapp
+</code></pre>
+</div>
+<p>, e.g.</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>src/main/webapp/template
+</code></pre>
+</div>
+<p>). In that folder I created checkboxlist.ftl and copied the contents from template.simple checkboxlist.ftl (again found in the Struts 2 core jar). After copying the contents to checkboxlist.ftl that is in KUTheme_simple folder, I modified checkboxlist.ftl so that the label tag has a style of red bold text and I added a break tag after each label so that each check box and label will be on its own line.</p>
+
+<p>Since the XHTML theme is the default theme and I have a theme.properties file defined with parent = xhtml, the KUTheme will inherit all the themes from xhmtl exempt for the theme for the checkboxlist tag since my KUTheme includes a definition for that tag’s layout.  In the struts.xml file (src/main/resources) you will see that the I’ve specified the default theme to be KUTheme.</p>
+
+<p>In the deployed web application, Struts 2 will first look for a tag’s template on the application’s class path and if it doesn’t find the template there it will use the default template that is part of the Struts 2 core jar. Since we’ve added a template folder to the application’s web root, now when Struts 2 creates the HTML to display the checkboxlist tag it will use the template that is in the KUTheme folder (which tells it to use the checkboxlist.ftl file that is in the KUTheme_simple folder instead of the one in the template.simple folder that is part of the Struts 2 core Jar).</p>
+
+<p>After redeploying the application the check boxes for the Car Models Owned should appear like:</p>
+
+<p><img src="attachments/att23527657_Screen shot 2010-09-11 at 12.37.12 PM.png" alt="Screen shot 2010-09-11 at 12.37.12 PM.png" /></p>
+
+<p>#####Summary#####</p>
+
+<p>You can easily override the default theme used by Struts 2 to control the appearance and layout of a Struts 2 tag. Each Struts 2 tag has an associated template file (e.g. select.ftl) that is in a folder named after the theme (e.g. xhtml). By default the Struts framework will look in the Struts 2 core Jar file for the theme folder and templates. However, if you include your own theme folder (e.g. KUTheme) under webapp/template (or WebContent/template in the Ant version) and specify that folder name (e.g. KUTheme) as the value for the theme attribute, then the Struts 2 framework will look in that theme folder for the tag’s template.</p>
+
+<p>To learn more about how to use the Struts 2 themes and how you can override them, visit <em>Themes and Templates Documentation</em> .</p>
+
+  </section>
+</article>
+
+
+<footer class="container">
+  <div class="col-md-12">
+    Copyright &copy; 2000-2016 <a href="http://www.apache.org/">The Apache Software Foundation </a>.
+    All Rights Reserved.
+  </div>
+  <div class="col-md-12">
+    Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project logos are
+    trademarks of The Apache Software Foundation.
+  </div>
+  <div class="col-md-12">Logo and website design donated by <a href="https://softwaremill.com/">SoftwareMill</a>.</div>
+</footer>
+
+<script>!function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (!d.getElementById(id)) {
+    js = d.createElement(s);
+    js.id = id;
+    js.src = "//platform.twitter.com/widgets.js";
+    fjs.parentNode.insertBefore(js, fjs);
+  }
+}(document, "script", "twitter-wjs");</script>
+<script src="https://apis.google.com/js/platform.js" async="async" defer="defer"></script>
+
+<div id="fb-root"></div>
+
+<script>(function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (d.getElementById(id)) return;
+  js = d.createElement(s);
+  js.id = id;
+  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
+  fjs.parentNode.insertBefore(js, fjs);
+}(document, 'script', 'facebook-jssdk'));</script>
+
+
+<script>
+$(function() {
+  return $("h2, h3, h4, h5, h6").each(function(i, el) {
+    var $el, icon, id;
+    $el = $(el);
+    id = $el.attr('id');
+    icon = '<i class="fa fa-link"></i>';
+    if (id) {
+      return $el.prepend($("<a />").addClass("header-link").attr("href", "#" + id).html(icon));
+    }
+  });
+});
+</script>
+
+</body>
+</html>

Added: websites/production/struts/content/getting-started/unit-testing.html
==============================================================================
--- websites/production/struts/content/getting-started/unit-testing.html (added)
+++ websites/production/struts/content/getting-started/unit-testing.html Fri Mar 31 05:44:39 2017
@@ -0,0 +1,333 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8"/>
+  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+  <meta name="Date-Revision-yyyymmdd" content="20140918"/>
+  <meta http-equiv="Content-Language" content="en"/>
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+
+  <title>Unit testing</title>
+
+  <link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic,600italic,700italic" rel="stylesheet" type="text/css">
+  <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
+  <link href="/css/main.css" rel="stylesheet">
+  <link href="/css/custom.css" rel="stylesheet">
+
+  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+  <script type="text/javascript" src="/bootstrap/js/bootstrap.js"></script>
+  <script type="text/javascript" src="/js/community.js"></script>
+</head>
+<body>
+
+<a href="http://github.com/apache/struts" class="github-ribbon">
+  <img style="position: absolute; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub">
+</a>
+
+<header>
+  <nav>
+    <div role="navigation" class="navbar navbar-default navbar-fixed-top">
+      <div class="container">
+        <div class="navbar-header">
+          <button type="button" data-toggle="collapse" data-target="#struts-menu" class="navbar-toggle">
+            Menu
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+          <a href="/index.html" class="navbar-brand logo"><img src="/img/struts-logo.svg"></a>
+        </div>
+        <div id="struts-menu" class="navbar-collapse collapse">
+          <ul class="nav navbar-nav">
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Home<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/index.html">Welcome</a></li>
+                <li><a href="/downloads.html">Downloads</a></li>
+                <li><a href="/announce.html">Announcements</a></li>
+                <li><a href="http://www.apache.org/licenses/">License</a></li>
+                <li><a href="http://apache.org/foundation/thanks.html">Thanks!</a></li>
+                <li><a href="http://apache.org/foundation/sponsorship.html">Sponsorship</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Support<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/mail.html">User Mailing List</a></li>
+                <li><a href="https://issues.apache.org/jira/browse/WW">Issue Tracker</a></li>
+                <li><a href="/security.html">Reporting Security Issues</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/project-info.html">Project info</a></li>
+                <li><a href="/maven/struts2-core/dependencies.html">Struts Core dependencies</a></li>
+                <li><a href="/maven/struts2-plugins/modules.html">Plugin dependencies</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Documentation<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/birdseye.html">Birds Eye</a></li>
+                <li><a href="/primer.html">Key Technologies</a></li>
+                <li><a href="/kickstart.html">Kickstart FAQ</a></li>
+                <li><a href="https://cwiki.apache.org/confluence/display/WW/Home">Wiki</a></li>
+                <li class="divider"></li>
+                <li><a href="/docs/home.html">Getting started</a></li>
+                <li><a href="/docs/tutorials.html">Tutorials</a></li>
+                <li><a href="/docs/faqs.html">FAQs</a></li>
+                <li><a href="/docs/guides.html">Guides</a></li>
+                <li class="divider"></li>
+                <li><a href="/maven/struts2-core/apidocs/index.html">Struts Core API</a></li>
+                <li><a href="/docs/plugins.html">Plugin APIs</a></li>
+                <li><a href="/docs/tag-reference.html">Tag reference</a></li>
+                <li><a href="http://cwiki.apache.org/S2PLUGINS/home.html">Plugin registry</a></li>
+                <li class="divider"></li>
+                <li><a href="/getting-started/getting-started.html">Getting Started (WIP)</a></li>
+              </ul>
+            </li>
+            <li class="dropdown">
+              <a data-toggle="dropdown" href="#" class="dropdown-toggle">
+                Contributing<b class="caret"></b>
+              </a>
+              <ul class="dropdown-menu">
+                <li><a href="/youatstruts.html">You at Struts</a></li>
+                <li><a href="/helping.html">How to Help FAQ</a></li>
+                <li><a href="/dev-mail.html">Development Lists</a></li>
+                <li class="divider"></li>
+                <li><a href="/submitting-patches.html">Submitting patches</a></li>
+                <li><a href="/builds.html">Source Code</a></li>
+                <li><a href="/coding-standards.html">Coding standards</a></li>
+                <li class="divider"></li>
+                <li><a href="/releases.html">Release Guidelines</a></li>
+                <li><a href="/bylaws.html">PMC Charter</a></li>
+                <li><a href="/volunteers.html">Volunteers</a></li>
+                <li><a href="https://git-wip-us.apache.org/repos/asf?p=struts.git">Source Repository</a></li>
+              </ul>
+            </li>
+            <li class="apache"><a href="http://www.apache.org/"><img src="/img/apache.png"></a></li>
+          </ul>
+        </div>
+      </div>
+    </div>
+  </nav>
+</header>
+
+
+<article class="container">
+  <section class="col-md-12">
+    <h2 id="unit-testing">Unit Testing</h2>
+
+<p>The example code for this tutorial, unit_testing, is available at <a href="https://github.com/apache/struts-examples">https://github.com/apache/struts-examples</a></p>
+
+<blockquote>
+
+</blockquote>
+
+<p>#####Introduction#####</p>
+
+<p>Struts 2 supports running unit tests of methods in the Struts Action class with the <a href="http://struts.apache.org/2.3.1.2/docs/junit-plugin.html">Struts 2 JUnit plugin</a>^[http://struts.apache.org/2.3.1.2/docs/junit-plugin.html]. The JUnit plugin allows you to test methods of an Action class from within the Struts 2 framework. The Struts Servlet filter and interceptors fire just as if your application was running on a Servlet container.</p>
+
+<table>
+  <tbody>
+    <tr>
+      <td>The <a href="http://struts.apache.org/mail.html">Struts 2 user mailing list</a>^[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.</td>
+    </tr>
+  </tbody>
+</table>
+
+<table>
+  <tbody>
+    <tr>
+    </tr>
+  </tbody>
+</table>
+
+<p>#####Setup#####</p>
+
+<p>The Struts 2 JUnit plugin jar file must be on your application’s class path. In the example application (see info above) the pom.xml includes a dependency for the struts2-junit-plugin. There are numerous transitive dependencies, including to JUnit and the Spring framework.</p>
+
+<p>#####Writing A Unit Test#####</p>
+
+<p>In the example application, the Register Action class includes using the validate method. This method is automatically executed by the Struts 2 framework prior to the execute method. Additionally, this method needs the values from the user’s input on the form to already have been provided to the instance fields of the Action class (this work is done by another Struts 2 interceptor). So it would be difficult to test the validate method without the overall Struts 2 framework running.</p>
+
+<p>To use the Struts 2 plugin to ensure the Strut 2 framework runs as part of the test, you need to have your JUnit test class extend StrutsTestCase (see RegisterTest class in the example application).</p>
+
+<blockquote>
+
+</blockquote>
+
+<blockquote>
+
+</blockquote>
+
+<blockquote>
+  <p>Note that the Struts 2 JUnit plugin can be used to design unit tests of other Action class methods such as the input method and also to test methods of a custom interceptor you add to the interceptor stack. Also in this example, the test is for validation performed in the <em>validate method</em> . But the same type of test would work if the validation was done using <a href="#PAGE_20644608">XML file validation</a>.</p>
+</blockquote>
+
+<blockquote>
+
+</blockquote>
+
+<p>To test the validate method we want Struts to call the Struts action that will cause the Action class’s validate and execute methods to be run. In the example application this action is register.</p>
+
+<p><strong>struts.xml</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>	  &lt;action name="register" class="org.apache.struts.register.action.Register" method="execute"&gt;
+		&lt;result name="success"&gt;/thankyou.jsp&lt;/result&gt;
+		&lt;result name="input"&gt;/register.jsp&lt;/result&gt;
+	  &lt;/action&gt;
+
+
+</code></pre>
+</div>
+
+<p>Remember the validate method will be called automatically by the framework before calling the execute method. If validation fails the Struts framework will return “input”. If there are no validation errors then the framework will call the execute method and return whatever String the execute method returns.</p>
+
+<p>#####Test Validation Should Pass#####</p>
+
+<p>For our first test we’ll test that there should be no validation errors. In the normal flow of this application the user would first enter the form data shown on the register.jsp page.</p>
+
+<p><img src="attachments/att28017281_Screen shot 2012-02-17 at 2.46.54 PM.png" alt="Screen shot 2012-02-17 at 2.46.54 PM.png" /></p>
+
+<p>The input fields for the form have the following name values: personBean.firstName, personBean.lastName, personBean.email, and personBean.age. When the user fills out those fields Struts will take the values and provide them to the appropriate set methods of the personBean object. So as part of the test I need to simulate the user filling out these form fields. The StrutsTestCase provides a request object (of type MockHttpServletRequest) that I can use to set these values in the request scope.</p>
+
+<p><strong>testExecuteValidationPasses method from RegisterTest class</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>@Test
+public void testExecuteValidationPasses() throws Exception() {
+
+  request.setParameter("personBean.firstName", "Bruce");
+
+  request.setParameter("personBean.lastName", "Phillips");
+		
+  request.setParameter("personBean.email", "bphillips@ku.edu");
+		
+  request.setParameter("personBean.age", "19");
+
+  ActionProxy actionProxy = getActionProxy("/register.action");
+
+  Register action = (Register) actionProxy.getAction() ;
+
+  assertNotNull("The action is null but should not be.", action);
+
+  String result - actionProxy.execute();
+
+  assertEquals("The execute method did not return " + ActionSupport.SUCCESS + " but should have.", ActionSupport.SUCCESS, result);
+  
+}
+
+
+</code></pre>
+</div>
+
+<p>The first statements in the test method use the request object to set the values of any request parameters. These simulate the values the user would enter into the form fields. Note how the first argument to setParameter is the same as the value of the name attribute in the Struts textfield tag in the register.jsp page.</p>
+
+<p>In this test I’m providing good data for each form field as I want to ensure my validation doesn’t register an error if the user provides correct information.</p>
+
+<p>I then call the getActionProxy method with the argument of “/register.action” and then the getAction method to get a reference to the Struts action class for this test. This will ensure that the Struts 2 JUnit plugin will know which Action class should be used–the class associated with the register action in the struts.xml. In this case that class is the Register class.</p>
+
+<p>The assertNotNull test ensures that argument to getActionProxy reference an Action class identified in struts.xml. It’s a way of checking that you’ve correctly setup struts.xml for this action.</p>
+
+<p>After that I can call actionProxy.execute(). This causes the Struts 2 framework to go through its normal process of Servlet fileter and interceptors for the action identified by the actionProxy (in this case that is the register.action). The validate method of class Register will get called and if it doesn’t create any field or action errors then Struts 2 will call the execute method. In this example, the execute method should return “success”.</p>
+
+<p>So in the next statement, I check that success was returned.</p>
+
+<p>#####Test Validation Should Fail#####</p>
+
+<p>To test that validation should fail, I just need to have a test method that doesn’t provide input for a form field. For example, in the validate method of the Register Action class, is a test to ensure the user has entered some information for the personBean.firstName input field. In the test method I would just not use the request object to set a parameter for that field.</p>
+
+<p><strong>testExecuteValidationFailsMissingFirstName method from RegisterTest class</strong></p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code>@Test
+public void testExecuteValidationFailsMissingFirstName() throws Exception() {
+
+  //request.setParameter("personBean.firstName", "Bruce");
+
+  request.setParameter("personBean.lastName", "Phillips");
+		
+  request.setParameter("personBean.email", "bphillips@ku.edu");
+		
+  request.setParameter("personBean.age", "19");
+
+  ActionProxy actionProxy = getActionProxy("/register.action");
+
+  Register action = (Register) actionProxy.getAction() ;
+
+  assertNotNull("The action is null but should not be.", action);
+
+  String result - actionProxy.execute();
+
+  assertEquals("The execute method did not return " + ActionSupport.INPUT + " but should have.", ActionSupport.INPUT, result);
+  
+}
+
+
+</code></pre>
+</div>
+
+<p>In the last assertEquals statement my test checks that the Struts 2 framework returned “input” as that is what the Struts 2 framework will return if the validation adds a field or action error.</p>
+
+<p>#####Summary#####</p>
+
+<p>There is much more you can do with the Struts 2 JUnit plugin to help you test the methods of your Action class in conjunction with the Struts 2 fraemwork. If your Struts 2 application uses Spring to inject dependencies into the Action class then the Struts 2 JUnit Plugin has a StrutsSpringTestCase that your test class should extend. Please read <a href="http://struts.apache.org/2.3.1.2/docs/testing-actions.html">Testing Actions</a>^[http://struts.apache.org/2.3.1.2/docs/testing-actions.html] to learn more.</p>
+
+  </section>
+</article>
+
+
+<footer class="container">
+  <div class="col-md-12">
+    Copyright &copy; 2000-2016 <a href="http://www.apache.org/">The Apache Software Foundation </a>.
+    All Rights Reserved.
+  </div>
+  <div class="col-md-12">
+    Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project logos are
+    trademarks of The Apache Software Foundation.
+  </div>
+  <div class="col-md-12">Logo and website design donated by <a href="https://softwaremill.com/">SoftwareMill</a>.</div>
+</footer>
+
+<script>!function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (!d.getElementById(id)) {
+    js = d.createElement(s);
+    js.id = id;
+    js.src = "//platform.twitter.com/widgets.js";
+    fjs.parentNode.insertBefore(js, fjs);
+  }
+}(document, "script", "twitter-wjs");</script>
+<script src="https://apis.google.com/js/platform.js" async="async" defer="defer"></script>
+
+<div id="fb-root"></div>
+
+<script>(function (d, s, id) {
+  var js, fjs = d.getElementsByTagName(s)[0];
+  if (d.getElementById(id)) return;
+  js = d.createElement(s);
+  js.id = id;
+  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
+  fjs.parentNode.insertBefore(js, fjs);
+}(document, 'script', 'facebook-jssdk'));</script>
+
+
+<script>
+$(function() {
+  return $("h2, h3, h4, h5, h6").each(function(i, el) {
+    var $el, icon, id;
+    $el = $(el);
+    id = $el.attr('id');
+    icon = '<i class="fa fa-link"></i>';
+    if (id) {
+      return $el.prepend($("<a />").addClass("header-link").attr("href", "#" + id).html(icon));
+    }
+  });
+});
+</script>
+
+</body>
+</html>



Mime
View raw message