Author: lukaszlenart
Date: Tue Apr 25 05:19:47 2017
New Revision: 1011089

Log:
Updates production

Removed:
    
websites/production/struts/content/getting-started/attachments/att14974997_hellobruce.png
    
websites/production/struts/content/getting-started/attachments/att14974998_personalhello.png
Modified:
    websites/production/struts/content/getting-started/coding-actions.html

Modified: websites/production/struts/content/getting-started/coding-actions.html
==============================================================================
--- websites/production/struts/content/getting-started/coding-actions.html 
(original)
+++ websites/production/struts/content/getting-started/coding-actions.html Tue 
Apr 25 05:19:47 2017
@@ -124,9 +124,9 @@
     <a href="index.html" title="back to Getting Started"><< back to Getting 
Started</a>
     <h2 id="coding-actions">Coding actions</h2>
 
-<p>This tutorial assumes you’ve completed the <a href="#PAGE_14811875">Using 
Struts 2 Tags</a> tutorial and have a working using_tags project. The example 
code for this tutorial, coding_action, is available for checkout from the 
Struts 2 GitHub repository: <a 
href="https://github.com/apache/struts-examples";>https://github.com/apache/struts-examples</a>.</p>
+<p>This tutorial assumes you’ve completed the <a 
href="using-tags.html">Using Struts 2 Tags</a> tutorial and have a working 
using-tags project. The example code for this tutorial, coding-actions, is 
available for checkout from the Struts 2 GitHub repository: <a 
href="https://github.com/apache/struts-examples";>https://github.com/apache/struts-examples</a>.</p>
 
-<p><strong>Introduction</strong></p>
+<h3 id="introduction">Introduction</h3>
 
 <p>Coding a Struts 2 Action involves several parts:</p>
 
@@ -136,7 +136,7 @@
   <li>Writing the controller logic in the Action class</li>
 </ol>
 
-<p>In the previous tutorials we covered how to configure Struts to map a URL 
such as hello.action to a Action class such as HelloWorldAction (specifically 
the execute method).</p>
+<p>In the previous tutorials we covered how to configure Struts to map a URL 
such as <code class="highlighter-rouge">hello.action</code> to an Action class 
such as <code class="highlighter-rouge">HelloWorldAction</code> (specifically 
the execute method).</p>
 
 <p><strong>Action Mapping</strong></p>
 
@@ -146,19 +146,19 @@
 </code></pre>
 </div>
 
-<p>The Action mapping above also specified that if the execute method of class 
HelloWorldAction returns success then the view HelloWorld.jsp will be returned 
to the browser.</p>
+<p>The Action mapping above also specified that if the <code 
class="highlighter-rouge">execute</code> method of class <code 
class="highlighter-rouge">HelloWorldAction</code> returns <code 
class="highlighter-rouge">success</code> then the view <code 
class="highlighter-rouge">HelloWorld.jsp</code> will be returned to the 
browser.</p>
 
 <p>This tutorial will introduce you to the basics of writing the controller 
logic in the Action class.</p>
 
-<p><strong>Struts 2 Action Classes</strong></p>
+<h3 id="struts-2-action-classes">Struts 2 Action Classes</h3>
 
 <p>Action classes act as the controller in the MVC pattern. Action classes 
respond to a user action, execute business logic (or call upon other classes to 
do that), and then return a result that tells Struts what view to render.</p>
 
 <p>Struts 2 Action classes usually extend the <code 
class="highlighter-rouge">ActionSupport</code> class, which is provided by the 
Struts 2 framework. Class <code class="highlighter-rouge">ActionSupport</code> 
provides default implementations for the most common actions (e.g. execute, 
input) and also implements several useful Struts 2 interfaces. When your Action 
class extends class <code class="highlighter-rouge">ActionSupport</code> your 
class can either override the default implementations or inherit them.</p>
 
-<p>If you examine class HelloWorldAction from tutorial <a 
href="using-tags.html">Using Struts 2 Tags</a> you’ll see that it extends 
class <code class="highlighter-rouge">ActionSupport</code> and then overrides 
method execute.</p>
+<p>If you examine class HelloWorldAction from tutorial <a 
href="using-tags.html">Using Struts 2 Tags</a> you’ll see that it extends the 
class <code class="highlighter-rouge">ActionSupport</code> and then overrides 
method <code class="highlighter-rouge">execute</code>.</p>
 
-<p>In method execute is where we placed what we want this controller to do in 
response to the hello.action.</p>
+<p>The method <code class="highlighter-rouge">execute</code> is where we 
placed what we want this controller to do in response to the <code 
class="highlighter-rouge">hello.action</code>.</p>
 
 <p><strong>Method execute of HelloWorldAction</strong></p>
 
@@ -175,11 +175,11 @@
   <p>Note that method execute declares it throws an Exception. We’ll cover 
in a later tutorial how to configure Struts to handle any Exceptions thrown 
from the Action classes methods.</p>
 </blockquote>
 
-<p><strong>Processing Form Input In The Action Class</strong></p>
+<h3 id="processing-form-input-in-the-action-class">Processing Form Input In 
The Action Class</h3>
 
-<p>One of the most common responsibilities of the Action class is to process 
user input on a form and then make the result of the processing available to 
the view page. To illustrate this responsibility, let’s say that on our view 
page, HelloWorld.jsp, we want to display a personal hello, such as “Hello 
Struts User Bruce.”</p>
+<p>One of the most common responsibilities of the Action class is to process 
user input on a form and then make the result of the processing available to 
the view page. To illustrate this responsibility, let’s say that on our view 
page, <code class="highlighter-rouge">HelloWorld.jsp</code>, we want to display 
a personal hello, such as “Hello Struts User Bruce.”</p>
 
-<p>In the <a href="using-tags.html">Using Struts 2 Tags</a> example 
application we added a Struts 2 form to index.jsp.</p>
+<p>In the <a href="using-tags.html">Using Struts 2 Tags</a> example 
application we added a Struts 2 form to <code 
class="highlighter-rouge">index.jsp</code>.</p>
 
 <p><strong>Struts 2 Form Tags</strong></p>
 
@@ -190,11 +190,11 @@
 </code></pre>
 </div>
 
-<p>Make a note of the value of the name attribute for the Struts 2 textfield 
tag, which is userName. When the user clicks on the submit button for the above 
form, the action hello will be executed (hello.action). The form field values 
will be posted to the Struts 2 Action class (HelloWorldAction). The Action 
class may automatically receive those form field values provided it has a 
public set method that matches the form field name value.</p>
+<p>Make a note of the value of the name attribute for the Struts 2 textfield 
tag, which is userName. When the user clicks on the submit button for the above 
form, the action hello will be executed (<code 
class="highlighter-rouge">hello.action</code>). The form field values will be 
posted to the Struts 2 Action class (<code 
class="highlighter-rouge">HelloWorldAction</code>). The Action class may 
automatically receive those form field values provided it has a public set 
method that matches the form field name value.</p>
 
 <p>So for the HelloWorldAction class to automatically receive the userName 
value it must have a public method setUserName (note the JavaBean convention 
discussed in tutorial <a href="hello-world-using-struts2.html">Hello 
World</a>).</p>
 
-<p>For the example application associated with this tutorial add the following 
Java code to class HelloWorldAction.</p>
+<p>For the example application associated with this tutorial, add the 
following Java code to class <code 
class="highlighter-rouge">HelloWorldAction</code>.</p>
 
 <p><strong>Add userName to HelloWorldAction</strong></p>
 
@@ -220,21 +220,21 @@
 </code></pre>
 </div>
 
-<p>Now build and deploy the application. Enter your name in the form and click 
the submit button. You should see the following page.</p>
+<p>Now build and run (<code class="highlighter-rouge">mvn jetty:run</code>) 
the application. Enter your name in the form and click the submit button. You 
should see the following page.</p>
 
-<p><img src="attachments/att14974998_personalhello.png" 
alt="personalhello.png" /></p>
+<p><img src="attachments/coding_actions_form_submit_result.png" 
alt="coding_actions_form_submit_result.png" /></p>
 
-<p>When the form is submitted, Struts will call any set methods of the 
HelloWorldAction class that match the form field names. So in this example 
method setUserName was called and passed the value the user entered in the 
userName form field.</p>
+<p>When the form is submitted, Struts will call any set methods of the 
HelloWorldAction class that match the form field names. So in this example 
method <code class="highlighter-rouge">setUserName</code> was called and passed 
the value the user entered in the <code 
class="highlighter-rouge">userName</code> form field.</p>
 
-<p>On the index.jsp we also have a Struts 2 action link (see tutorial <a 
href="using-tags.html">Using Struts 2 Tags</a>) that includes a query string 
parameter: userName=Bruce+Phillips. If you click on that link you should see 
the result of:</p>
+<p>On the <code class="highlighter-rouge">index.jsp</code> we also have a 
Struts 2 action link (see tutorial <a href="using-tags.html">Using Struts 2 
Tags</a>) that includes a query string parameter: <code 
class="highlighter-rouge">userName=Bruce+Phillips</code>. If you click on that 
link you should see the following result:</p>
 
-<p><img src="attachments/att14974997_hellobruce.png" alt="hellobruce.png" 
/></p>
+<p><img src="attachments/coding_actions_link_with_param_result.png" 
alt="coding_actions_link_with_param_result.png" /></p>
 
-<p>Since the query string parameter is userName, Struts passed the value of 
that parameter to the setUserName method.</p>
+<p>Since the query string parameter is <code 
class="highlighter-rouge">userName</code>, Struts passed the value of that 
parameter to the <code class="highlighter-rouge">setUserName</code> method.</p>
 
-<p>On the view page, HelloWorld.jsp, you can also access the userName value by 
using the Struts 2 property tag (see tutorial <a href="using-tags.html">Using 
Struts 2 Tags</a>). Try showing just the userName value on the view page.</p>
+<p>On the view page, <code class="highlighter-rouge">HelloWorld.jsp</code>, 
you can also access the <code class="highlighter-rouge">userName</code> value 
by using the Struts 2 property tag (see tutorial <a 
href="using-tags.html">Using Struts 2 Tags</a>). Try showing just the <code 
class="highlighter-rouge">userName</code> value on the view page.</p>
 
-<p><strong>Summary</strong></p>
+<h3 id="summary">Summary</h3>
 
 <p>This tutorial introduced you to how to code the Action class so it can 
process user input on a form or values in a query string parameter. If the form 
had numerous fields, it would be cumbersome to have a set method that matches 
up with each form field. So our next tutorial will cover how to integrate a 
model class, form fields in the view and form processing in the Action 
class.</p>
 


Reply via email to