struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1014670 - in /websites/production/struts/content/core-developers: ajax.html nutshell.html
Date Wed, 28 Jun 2017 15:49:47 GMT
Author: lukaszlenart
Date: Wed Jun 28 15:49:47 2017
New Revision: 1014670

Log:
Updates production

Modified:
    websites/production/struts/content/core-developers/ajax.html
    websites/production/struts/content/core-developers/nutshell.html

Modified: websites/production/struts/content/core-developers/ajax.html
==============================================================================
--- websites/production/struts/content/core-developers/ajax.html (original)
+++ websites/production/struts/content/core-developers/ajax.html Wed Jun 28 15:49:47 2017
@@ -125,169 +125,147 @@
     <a href="index.html" title="back to Core Developers Guide"><< back to Core Developers Guide</a>
     <h1 id="ajax">AJAX</h1>
 
-<p>AJAX is an acronym for Asynchronous JavaScript and XML. Essentially, a JavaScript can make a HTTP request and update portions of a page directly, without going through a conventional POST or GET and refreshing the entire page. Better yet, a page can contain several JavaScripts making simultaneous (asynchronous) requests.</p>
-
-<p>The key point is that when a script makes an “Ajax request” (XHR), the server doesn’t know it came from a script, and handles it like any other request. One reason Ajax is so successful is that it works just fine with existing server technologies, including Struts.</p>
-
-<p>It’s not the Ajax request that is different, but the Ajax response. Instead of returning an entire page for the browser to display (or redisplay), an Ajax response will just return a portion of a page. The response can take the form of XML, or HTML, or plain text, another script, or whatever else the calling script may want.</p>
-
-<p>Both Struts 1 and Struts 2 can return any type of response. We are not limited to forwarding to a server page. In Struts 1, you can just do something like:</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>response.setContentType("text/html");
-PrintWriter out = response.getWriter();
-out.println("Hello World!  This is an AJAX response from a Struts Action.");
-out.flush();
-return null;
-
+<p>AJAX is an acronym for Asynchronous JavaScript and XML. Essentially, a JavaScript can make a HTTP request and update 
+portions of a page directly, without going through a conventional POST or GET and refreshing the entire page. 
+Better yet, a page can contain several JavaScripts making simultaneous (asynchronous) requests.</p>
+
+<p>The key point is that when a script makes an “Ajax request” (XHR), the server doesn’t know it came from a script, 
+and handles it like any other request. One reason Ajax is so successful is that it works just fine with existing server 
+technologies, including Struts.</p>
+
+<p>It’s not the Ajax request that is different, but the Ajax response. Instead of returning an entire page for the browser 
+to display (or redisplay), an Ajax response will just return a portion of a page. The response can take the form of XML, 
+or HTML, or plain text, another script, or whatever else the calling script may want.</p>
+
+<p>Both Struts 1 and Struts 2 can return any type of response. We are not limited to forwarding to a server page. 
+In Struts 1, you can just do something like:</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">response</span><span class="o">.</span><span class="na">setContentType</span><span class="o">(</span><span class="s">"text/html"</span><span class="o">);</span>
+<span class="n">PrintWriter</span> <span class="n">out</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="na">getWriter</span><span class="o">();</span>
+<span class="n">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"Hello World!  This is an AJAX response from a Struts Action."</span><span class="o">);</span>
+<span class="n">out</span><span class="o">.</span><span class="na">flush</span><span class="o">();</span>
+<span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
 </code></pre>
 </div>
 
 <p>In Struts 2, we can do the same thing with a Stream result.</p>
 
-<table>
-  <tbody>
-    <tr>
-      <td>Using a Struts 2 plugin (e.g., <em>JSON plugin</em> , jQuery plugin, etc.) is, in general, preferred to writing the response directly from within an action. See sections following this for further details.</td>
-    </tr>
-  </tbody>
-</table>
-
-<table>
-  <tbody>
-    <tr>
-    </tr>
-  </tbody>
-</table>
+<blockquote>
+  <p>Using a Struts 2 plugin (e.g., <em>JSON plugin</em> , jQuery plugin, etc.) is, in general, preferred to writing the response 
+directly from within an action. See sections following this for further details.</p>
+</blockquote>
 
 <p><strong>Struts 2 Stream result Action</strong></p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>package actions;
-
-import java.io.InputStream;
-import java.io.StringBufferInputStream;
-import com.opensymphony.xwork2.ActionSupport;
-
-public class TextResult extends ActionSupport  {
-    private InputStream inputStream;
-    public InputStream getInputStream() {
-        return inputStream;
-    }
-
-    public String execute() throws Exception {
-        inputStream = new ByteArrayInputStream("Hello World! This is a text string response from a Struts 2 Action.".getBytes("UTF-8"));
-        return SUCCESS;
-    }
-}
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="kn">package</span> <span class="n">actions</span><span class="o">;</span>
 
+<span class="kn">import</span> <span class="nn">java.io.InputStream</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">java.io.StringBufferInputStream</span><span class="o">;</span>
+<span class="kn">import</span> <span class="nn">com.opensymphony.xwork2.ActionSupport</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kd">class</span> <span class="nc">TextResult</span> <span class="kd">extends</span> <span class="n">ActionSupport</span>  <span class="o">{</span>
+    <span class="kd">private</span> <span class="n">InputStream</span> <span class="n">inputStream</span><span class="o">;</span>
+    <span class="kd">public</span> <span class="n">InputStream</span> <span class="n">getInputStream</span><span class="o">()</span> <span class="o">{</span>
+        <span class="k">return</span> <span class="n">inputStream</span><span class="o">;</span>
+    <span class="o">}</span>
+
+    <span class="kd">public</span> <span class="n">String</span> <span class="n">execute</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
+        <span class="n">inputStream</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ByteArrayInputStream</span><span class="o">(</span><span class="s">"Hello World! This is a text string response from a Struts 2 Action."</span><span class="o">.</span><span class="na">getBytes</span><span class="o">(</span><span class="s">"UTF-8"</span><span class="o">));</span>
+        <span class="k">return</span> <span class="n">SUCCESS</span><span class="o">;</span>
+    <span class="o">}</span>
+<span class="o">}</span>
 </code></pre>
 </div>
 
 <p><strong>Struts 2 Configuring the TextResult Action</strong></p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>&lt;action name="text-result" class="actions.TextResult"&gt;
-    &lt;result type="stream"&gt;
-        &lt;param name="contentType"&gt;text/html&lt;/param&gt;
-        &lt;param name="inputName"&gt;inputStream&lt;/param&gt;
-    &lt;/result&gt;
-&lt;/action&gt;
-
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;action</span> <span class="na">name=</span><span class="s">"text-result"</span> <span class="na">class=</span><span class="s">"actions.TextResult"</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;result</span> <span class="na">type=</span><span class="s">"stream"</span><span class="nt">&gt;</span>
+        <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">"contentType"</span><span class="nt">&gt;</span>text/html<span class="nt">&lt;/param&gt;</span>
+        <span class="nt">&lt;param</span> <span class="na">name=</span><span class="s">"inputName"</span><span class="nt">&gt;</span>inputStream<span class="nt">&lt;/param&gt;</span>
+    <span class="nt">&lt;/result&gt;</span>
+<span class="nt">&lt;/action&gt;</span>
 </code></pre>
 </div>
 
-<p>(ok)  Struts 2 can also return a JSON (JavaScript Object Notation) response, using a <a href="http://cwiki\.apache\.org/S2PLUGINS/json\-plugin\.html">plugin</a>^[http://cwiki.apache.org/S2PLUGINS/json-plugin.html].</p>
+<blockquote>
+  <p>Struts 2 can also return a JSON (JavaScript Object Notation) response, using a <a href="http://cwiki.apache.org/S2PLUGINS/json-plugin.html">plugin</a>.</p>
+</blockquote>
 
 <p>On the client side, there are two basic strategies, which can be mixed and matched.</p>
 
-<p>First, you can use some type of JSP tag. Here, you don’t have to know very much at all about Ajax or JavaScript. The taglib does all the work, and you just have to figure out how to use the taglib. The standard Struts 2 taglib includes several <em>Ajax JSP tags</em> , and many third-party libraries are available, including:</p>
+<p>First, you can use some type of JSP tag. Here, you don’t have to know very much at all about Ajax or JavaScript. 
+The taglib does all the work, and you just have to figure out how to use the taglib. The standard Struts 2 taglib 
+includes several <em>Ajax JSP tags</em> , and many third-party libraries are available, including:</p>
 
 <ul>
-  <li>
-    <p><a href="http://ajaxtags\.sourceforge\.net/">Ajax Tags</a>^[http://ajaxtags.sourceforge.net/]</p>
-  </li>
-  <li>
-    <p><a href="http://javawebparts\.sourceforge\.net/">AjaxParts Taglib</a>^[http://javawebparts.sourceforge.net/]</p>
-  </li>
-  <li>
-    <p><a href="http://servletsuite\.blogspot\.com/2006/06/coldtags\-suite\-ajax\-edition\.html">ColdTags Suite</a>^[http://servletsuite.blogspot.com/2006/06/coldtags-suite-ajax-edition.html]</p>
-  </li>
-  <li>
-    <p><a href="http://www\.jenkov\.com/prizetags/introduction\.tmpl">Prize Tags</a>^[http://www.jenkov.com/prizetags/introduction.tmpl]</p>
-  </li>
-  <li>
-    <p><a href="http://json\-taglib\.sourceforge\.net/">JSON-taglib</a>^[http://json-taglib.sourceforge.net/]</p>
-  </li>
+  <li><a href="http://ajaxtags.sourceforge.net/">Ajax Tags</a></li>
+  <li><a href="http://javawebparts.sourceforge.net/">AjaxParts Taglib</a></li>
+  <li><a href="http://servletsuite.blogspot.com/2006/06/coldtags-suite-ajax-edition.html">ColdTags Suite</a></li>
+  <li><a href="http://www.jenkov.com/prizetags/introduction.tmpl">Prize Tags</a></li>
+  <li><a href="http://json-taglib.sourceforge.net/">JSON-taglib</a></li>
 </ul>
 
-<p>Alternatively, you can use a plain-old Ajax widget on a plain-old HTML page, using libraries like <a href="http://dojotoolkit\.org/">Dojo</a>^[http://dojotoolkit.org/], <a href="http://jquery\.com/">JQuery</a>^[http://jquery.com/], or <a href="http://developer\.yahoo\.com/yui/">YUI</a>^[http://developer.yahoo.com/yui/], and the StreamResult or the <a href="http://cwiki\.apache\.org/S2PLUGINS/json\-plugin\.html">JSON Plugin</a>^[http://cwiki.apache.org/S2PLUGINS/json-plugin.html]. Here, the sky’s the limit, but you actually have to learn something about JavaScript as a language.</p>
+<p>Alternatively, you can use a plain-old Ajax widget on a plain-old HTML page, using libraries like 
+<a href="http://dojotoolkit.org/">Dojo</a>, <a href="http://jquery.com/">JQuery</a>, or <a href="http://developer.yahoo.com/yui/">YUI</a>, 
+and the StreamResult or the <a href="http://cwiki.apache.org/S2PLUGINS/json-plugin.html">JSON Plugin</a>. 
+Here, the sky’s the limit, but you actually have to learn something about JavaScript as a language.</p>
 
-<p>####Ajax Plugins####</p>
+<h2 id="ajax-plugins">Ajax Plugins</h2>
 
 <p>While Struts works fine with Ajax out-of-the-box, for added value, several Ajax-centric plugins are available.</p>
 
-<p>#####Ajax Tag Plugins#####</p>
+<h3 id="ajax-tag-plugins">Ajax Tag Plugins</h3>
 
 <ul>
-  <li>
-    <p><strong>jQuery</strong> - The <a href="https://github\.com/struts\-community\-plugins/struts2\-jquery">jQuery Plugin</a>^[https://github.com/struts-community-plugins/struts2-jquery] provide ajax functionality and UI Widgets an JavaScript Grid based on the jQuery javascript framework.**
-**</p>
-  </li>
-  <li>
-    <p><strong>Ajax Parts</strong> - The <a href="http://code\.google\.com/p/struts2ajaxpartstaglibplugin/">AjaxParts Taglib (APT)</a>^[http://code.google.com/p/struts2ajaxpartstaglibplugin/] is a component of the Java Web Parts (JWP) project (<a href="http://javawebparts\.sourceforge\.net">http://javawebparts.sourceforge.net</a>) that allows for 100% declarative (read: no Javascript coding required!) AJAX functionality within a Java-based webapp.</p>
-  </li>
-  <li>
-    <p><strong>Dojo</strong> - The <em>Ajax Tags Dojo Plugin</em>  was represented as a theme for Struts 2.0. For Struts 2.1, the Dojo tags are bundled as a plugin until version 2.3.x. Since version 2.5 this plugin is not part of th Struts2 distribution anymore </p>
-  </li>
-  <li>
-    <p><strong>YUI</strong> - The <a href="https://code\.google\.com/p/struts2yuiplugin/">Yahoo User Interface (YUI) Plugin</a>^[https://code.google.com/p/struts2yuiplugin/] has only a few tags are available so far, but the YUI tags tend to be easier to use than the Dojo versions.</p>
-  </li>
+  <li><strong>jQuery</strong> - The <a href="https://github.com/struts-community-plugins/struts2-jquery">jQuery Plugin</a> provides ajax 
+functionality and UI Widgets an JavaScript Grid based on the jQuery javascript framework.</li>
+  <li><strong>Ajax Parts</strong> - The <a href="http://code.google.com/p/struts2ajaxpartstaglibplugin/">AjaxParts Taglib (APT)</a> is a component 
+of the Java Web Parts (JWP) project (<a href="http://javawebparts.sourceforge.net">http://javawebparts.sourceforge.net</a>) that 
+allows for 100% declarative (read: no Javascript coding required!) AJAX functionality within a Java-based webapp.</li>
+  <li><strong>Dojo</strong> - The <em>Ajax Tags Dojo Plugin</em>  was represented as a theme for Struts 2.0. For Struts 2.1, the Dojo tags are 
+bundled as a plugin until version 2.3.x. Since version 2.5 this plugin is not part of th Struts2 distribution anymore. </li>
+  <li><strong>YUI</strong> - The <a href="https://code.google.com/p/struts2yuiplugin/">Yahoo User Interface (YUI) Plugin</a> has only a few tags 
+are available so far, but the YUI tags tend to be easier to use than the Dojo versions.</li>
 </ul>
 
-<p>#####Other Ajax Plugins#####</p>
+<h3 id="other-ajax-plugins">Other Ajax Plugins</h3>
 
 <ul>
-  <li>
-    <p><strong>Ajax File Upload</strong> - With the <a href="http://www\.davidjc\.com/ajaxfileupload/demo\!input\.action">Ajax File Upload Plugin</a>^[http://www.davidjc.com/ajaxfileupload/demo!input.action] we can upload a file to the server and asynchronously monitor its progress.</p>
-  </li>
-  <li>
-    <p><strong>GWT</strong> - The <a href="https://code\.google\.com/p/struts2gwtplugin/">Google Web Toolkit Plugin</a>^[https://code.google.com/p/struts2gwtplugin/] exposes Struts 2 actions to the GWT RPC mechanism.</p>
-  </li>
-  <li>
-    <p><strong>JSON</strong> - The <em>JSON Plugin</em>  serializes Actions properties into JSON, making it easy to respond to JavaScript requests.</p>
-  </li>
+  <li><strong>Ajax File Upload</strong> - With the <a href="http://www.davidjc.com/ajaxfileupload/demo!input.action">Ajax File Upload Plugin</a>
+we can upload a file to the server and asynchronously monitor its progress.</li>
+  <li><strong>GWT</strong> - The <a href="https://code.google.com/p/struts2gwtplugin/">Google Web Toolkit Plugin</a> exposes Struts 2 actions to 
+the GWT RPC mechanism.</li>
+  <li><strong>JSON</strong> - The <em>JSON Plugin</em>  serializes Actions properties into JSON, making it easy to respond to JavaScript requests.</li>
 </ul>
 
-<p>See the <a href="http://cwiki\.apache\.org/S2PLUGINS/home\.html">Struts Plugin Repository</a>^[http://cwiki.apache.org/S2PLUGINS/home.html] for a complete list of Struts 2 plugins.</p>
+<p>See the <a href="http://cwiki.apache.org/S2PLUGINS/home.html">Struts Plugin Repository</a> for a complete list of Struts 2 plugins.</p>
 
-<p>####Ajax Results with JSP####</p>
+<h2 id="ajax-results-with-jsp">Ajax Results with JSP</h2>
 
-<p>While server pages are most often used to generate HTML, we can use server pages to create other types of data streams. Here’s an example:</p>
+<p>While server pages are most often used to generate HTML, we can use server pages to create other types of data streams.
+Here’s an example:</p>
 
 <p><strong>book.jsp</strong></p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>&lt;%@ page import="java.util.Iterator,
-		 java.util.List,
-		 com.esolaria.dojoex.Book,
-		 com.esolaria.dojoex.BookManager" %&gt;
+<pre><code class="language-jsp">&lt;%@ page import="java.util.Iterator,
+    java.util.List,
+    com.esolaria.dojoex.Book,
+    com.esolaria.dojoex.BookManager" %&gt;
 &lt;%
-	String bookIdStr = request.getParameter("bookId");
-	int bookId = (bookIdStr == null || "".equals(bookIdStr.trim())) 
-		? 0 : Integer.parseInt(bookIdStr);
-	Book book = BookManager.getBook(bookId);
-	if (book != null) {
-		out.println(book.toJSONString());
-		System.out.println("itis: " + book.toJSONString());
-	}
+    String bookIdStr = request.getParameter("bookId");
+    int bookId = (bookIdStr == null || "".equals(bookIdStr.trim())) 
+        ? 0 : Integer.parseInt(bookIdStr);
+    Book book = BookManager.getBook(bookId);
+    if (book != null) {
+        out.println(book.toJSONString());
+        System.out.println("itis: " + book.toJSONString());
+    }
 %&gt;
-
 </code></pre>
-</div>
-
-<p>In the code example, we use</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>System.out.println
-</code></pre>
-</div>
-<p>to return a JSON data stream as the response. For more about this technique, see the article <a href="http://today\.java\.net/pub/a/today/2006/04/27/building\-ajax\-with\-dojo\-and\-json\.html">Using Dojo and JSON to Build Ajax Applications</a>^[http://today.java.net/pub/a/today/2006/04/27/building-ajax-with-dojo-and-json.html].</p>
+<p>In the code example, we use <code class="highlighter-rouge">System.out.println</code> to return a JSON data stream as the response. For more about this 
+technique, see the article <a href="http://today.java.net/pub/a/today/2006/04/27/building-ajax-with-dojo-and-json.html">Using Dojo and JSON to Build Ajax Applications</a>.</p>
 
   </section>
 </article>

Modified: websites/production/struts/content/core-developers/nutshell.html
==============================================================================
--- websites/production/struts/content/core-developers/nutshell.html (original)
+++ websites/production/struts/content/core-developers/nutshell.html Wed Jun 28 15:49:47 2017
@@ -125,157 +125,145 @@
     <a href="index.html" title="back to Core Developers Guide"><< back to Core Developers Guide</a>
     <h1 id="nutshell">Nutshell</h1>
 
-<p>The framework documentation is written for active web developers and assumes a working knowledge about how Java web applications are built. For more about the underlying nuts and bolts, see the <a href="http://struts\.apache\.org/primer\.html">Key Technologies Primer</a>^[http://struts.apache.org/primer.html].</p>
+<p>The framework documentation is written for active web developers and assumes a working knowledge about how 
+Java web applications are built. For more about the underlying nuts and bolts, see 
+the <a href="../primer.html">Key Technologies Primer</a>.</p>
 
-<blockquote>
-
-</blockquote>
-
-<p>####Apache Struts 2 Architecture in a Nutshell####</p>
+<h2 id="apache-struts-2-architecture-in-a-nutshell">Apache Struts 2 Architecture in a Nutshell</h2>
 
 <p><img src="attachments/struts2-arch.png" alt="struts2-arch.png" /></p>
 
 <ol>
-  <li>The web browser requests a resource (/mypage.action, /reports/myreport.pdf, et cetera)\</li>
-  <li>The Filter Dispatcher looks at the request and determines the appropriate Action\</li>
-  <li>The Interceptors automatically apply common functionality to the request, like workflow, validation, and file upload handling\</li>
-  <li>The Action method executes, usually storing and/or retrieving information from a database\</li>
-  <li>The Result renders the output to the browser, be it HTML, images, PDF, or something else\</li>
+  <li>The web browser requests a resource - <code class="highlighter-rouge">/mypage.action</code>, <code class="highlighter-rouge">/reports/myreport.pdf</code>, etc</li>
+  <li>The Filter Dispatcher looks at the request and determines the appropriate Action</li>
+  <li>The Interceptors automatically apply common functionality to the request, like workflow, validation, and file upload handling</li>
+  <li>The Action method executes, usually storing and/or retrieving information from a database</li>
+  <li>The Result renders the output to the browser, be it HTML, images, PDF, or something else</li>
 </ol>
 
-<p>|
-|——————————————————————————————————————————|———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————â€
 ————————————————————————————————————————————-|</p>
+<h2 id="struts-tags-in-a-nutshell">Struts Tags in a nutshell</h2>
 
-<p>####Struts Tags in a nutshell####</p>
-
-<p>The Struts Tags help you create rich web applications with a minimum of coding. Often, much of the coding effort in a web application goes into the pages. The Struts Tags reduce effort by reducing code.</p>
+<p>The Struts Tags help you create rich web applications with a minimum of coding. Often, much of the coding effort 
+in a web application goes into the pages. The Struts Tags reduce effort by reducing code.</p>
 
 <div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;% User user = ... %&gt;
-&lt;form action="Profile_update.action" method="post"&gt;
-    &lt;table&gt;
-        &lt;tr&gt;
-            &lt;td align="right"&gt;&lt;label&gt;First name:&lt;/label&gt;&lt;/td&gt;
-            &lt;td&gt;&lt;input type="text" name="user.firstname" value="&lt;%=user.getFirstname() %&gt; /&gt;&lt;/td&gt;
+<span class="err">&lt;</span>% User user = ... %&gt;
+<span class="nt">&lt;form</span> <span class="na">action=</span><span class="s">"Profile_update.action"</span> <span class="na">method=</span><span class="s">"post"</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;table&gt;</span>
+        <span class="nt">&lt;tr&gt;</span>
+            <span class="nt">&lt;td</span> <span class="na">align=</span><span class="s">"right"</span><span class="nt">&gt;&lt;label&gt;</span>First name:<span class="nt">&lt;/label&gt;&lt;/td&gt;</span>
+            <span class="nt">&lt;td&gt;&lt;input</span> <span class="na">type=</span><span class="s">"text"</span> <span class="na">name=</span><span class="s">"user.firstname"</span> <span class="na">value=</span><span class="s">"&lt;%=user.getFirstname() %&gt; /&gt;&lt;/td&gt;
         &lt;/tr&gt;
         &lt;tr&gt;
-            &lt;td&gt;&lt;input type="radio" name="user.gender" value="0" id="user.gender0" 
-                &lt;% if (user.getGender()==0) { %&gt; checked="checked" %&gt; } %&gt; /&gt;
-            &lt;label for="user.gender0"&gt;Female&lt;/label&gt;
-        &lt;/tr&gt;
-    &lt;/table&gt;
-&lt;/form&gt;
+            &lt;td&gt;&lt;input type="</span><span class="na">radio</span><span class="err">"</span> <span class="na">name=</span><span class="s">"user.gender"</span> <span class="na">value=</span><span class="s">"0"</span> <span class="na">id=</span><span class="s">"user.gender0"</span> 
+                <span class="err">&lt;%</span> <span class="na">if</span> <span class="err">(</span><span class="na">user</span><span class="err">.</span><span class="na">getGender</span><span class="err">()==</span><span class="na">0</span><span class="err">)</span> <span class="err">{</span> <span class="err">%</span><span class="nt">&gt;</span> checked="checked" %&gt; } %&gt; /&gt;
+            <span class="nt">&lt;label</span> <span class="na">for=</span><span class="s">"user.gender0"</span><span class="nt">&gt;</span>Female<span class="nt">&lt;/label&gt;</span>
+        <span class="nt">&lt;/tr&gt;</span>
+    <span class="nt">&lt;/table&gt;</span>
+<span class="nt">&lt;/form&gt;</span>
 ...
-
-</code></pre>
-</div>
-
-<p>Looking over the markup, it’s easy to see why Java web development without the aid from a modern framework is hard!  So far, we’ve only coded two controls, and there are six more to go! Let’s rewrite and finish the form using Struts Tags.</p>
-
-<p>|\
-\
-<img src="/Users/lukaszlenart/Projects/Apache/struts\-site/target/md/attachments/att1846\_nutshell\.GIF" alt="nutshell.GIF" />
-|\
-&lt;s:actionerror/&gt;\
-&lt;s:form action=”Profile_update” validate=”true”&gt;\
-    &lt;s:textfield label=”Username” name=”username”/&gt;\
-    &lt;s:password label=”Password” name=”password”/&gt;\
-    &lt;s:password label=”(Repeat) Password” name=”password2”/&gt;\
-    &lt;s:textfield label=”Full Name” name=”fullName”/&gt;\
-    &lt;s:textfield label=”From Address” name=”fromAddress”/&gt;\
-    &lt;s:textfield label=”Reply To Address” name=”replyToAddress”/&gt;\
-    &lt;s:submit value=”Save” name=”Save”/&gt;\
-    &lt;s:submit action=”Register_cancel” value=”Cancel” name=”Cancel”  onclick=”form.onsubmit=null”/&gt;\
-&lt;/s:form&gt;\
- The Struts Tags also support validation and localization as first-class features. So not only is there less code, but there is <em>more</em>  utility. \
-In about the same amount of code as two conventional controls, the Struts Tags can create an entire data-input form with eight controls. Not only is there less code, but the code is easier to read and maintain. |
-|——————————————————————————————————————–|——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————â€
 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
 ———————————————————————————-|</p>
-
-<p>####Struts Configuration in a Nutshell####</p>
-
-<p>A web application uses a deployment descriptor to initialize resources like filters and listeners. The web deployment descriptor is formatted as a XML document and named</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>web.xml
 </code></pre>
 </div>
-<p>. Struts can either initialize its resources by scanning your classes using Java packages declared in this</p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>web.xml
-</code></pre>
-</div>
-<p>file, or you can have full control over the configuration via a configuration file, named</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
-</code></pre>
-</div>
-<p>. These resources include action mappings, to direct input to server-side Action classes, and result types, to select output pages.</p>
+<p>Looking over the markup, it’s easy to see why Java web development without the aid from a modern framework is hard!
+So far, we’ve only coded two controls, and there are six more to go! Let’s rewrite and finish the form using Struts Tags.</p>
 
-<p>Here’s a typical configuration (</p>
+<p><img src="attachments/att1846_nutshell.gif" alt="nutshell.gif" /></p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>struts.xml
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;s:actionerror/&gt;</span>
+<span class="nt">&lt;s:form</span> <span class="na">action=</span><span class="s">"Profile\_update"</span> <span class="na">validate=</span><span class="s">"true"</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;s:textfield</span> <span class="na">label=</span><span class="s">"Username"</span> <span class="na">name=</span><span class="s">"username"</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;s:password</span> <span class="na">label=</span><span class="s">"Password"</span> <span class="na">name=</span><span class="s">"password"</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;s:password</span> <span class="na">label=</span><span class="s">"(Repeat) Password"</span> <span class="na">name=</span><span class="s">"password2"</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;s:textfield</span> <span class="na">label=</span><span class="s">"Full Name"</span> <span class="na">name=</span><span class="s">"fullName"</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;s:textfield</span> <span class="na">label=</span><span class="s">"From Address"</span> <span class="na">name=</span><span class="s">"fromAddress"</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;s:textfield</span> <span class="na">label=</span><span class="s">"Reply To Address"</span> <span class="na">name=</span><span class="s">"replyToAddress"</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;s:submit</span> <span class="na">value=</span><span class="s">"Save"</span> <span class="na">name=</span><span class="s">"Save"</span><span class="nt">/&gt;</span>
+    <span class="nt">&lt;s:submit</span> <span class="na">action=</span><span class="s">"Register_cancel"</span> <span class="na">value=</span><span class="s">"Cancel"</span> <span class="na">name=</span><span class="s">"Cancel"</span>  <span class="na">onclick=</span><span class="s">"form.onsubmit=null"</span><span class="nt">/&gt;</span>
+<span class="nt">&lt;/s:form&gt;</span>
 </code></pre>
 </div>
-<p>) for a login workflow:</p>
-
-<div class="highlighter-rouge"><pre class="highlight"><code>
-&lt;struts&gt;
-    &lt;package name="default" extends="struts-default"&gt;
-        &lt;action name="Logon" class="mailreader2.Logon"&gt;
-            &lt;result name="input"&gt;/pages/Logon.jsp&lt;/result&gt;
-            &lt;result name="cancel" type="redirectAction"&gt;Welcome&lt;/result&gt;
-            &lt;result type="redirectAction"&gt;MainMenu&lt;/result&gt;
-            &lt;result name="expired" type="chain"&gt;ChangePassword&lt;/result&gt;
-        &lt;/action&gt;
-
-        &lt;action name="Logoff" class="mailreader2.Logoff"&gt;
-            &lt;result type="redirectAction"&gt;Welcome&lt;/result&gt;
-        &lt;/action&gt;
-    &lt;/package&gt;
-&lt;/struts&gt;
 
+<p>The Struts Tags also support validation and localization as first-class features. So not only is there less code, 
+but there is <em>more</em> utility. In about the same amount of code as two conventional controls, the Struts Tags can create 
+an entire data-input form with eight controls. Not only is there less code, but the code is easier to read and maintain.</p>
+
+<h2 id="struts-configuration-in-a-nutshell">Struts Configuration in a Nutshell</h2>
+
+<p>A web application uses a deployment descriptor to initialize resources like filters and listeners. The web deployment 
+descriptor is formatted as a XML document and named <code class="highlighter-rouge">web.xml</code>. Struts can either initialize its resources by scanning 
+your classes using Java packages declared in this <code class="highlighter-rouge">web.xml</code> file, or you can have full control over the configuration 
+via a configuration file, named <code class="highlighter-rouge">struts.xml</code>. These resources include action mappings, to direct input to server-side 
+Action classes, and result types, to select output pages.</p>
+
+<p>Here’s a typical configuration (<code class="highlighter-rouge">struts.xml</code>) for a login workflow:</p>
+
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;struts&gt;</span>
+    <span class="nt">&lt;package</span> <span class="na">name=</span><span class="s">"default"</span> <span class="na">extends=</span><span class="s">"struts-default"</span><span class="nt">&gt;</span>
+        <span class="nt">&lt;action</span> <span class="na">name=</span><span class="s">"Logon"</span> <span class="na">class=</span><span class="s">"mailreader2.Logon"</span><span class="nt">&gt;</span>
+            <span class="nt">&lt;result</span> <span class="na">name=</span><span class="s">"input"</span><span class="nt">&gt;</span>/pages/Logon.jsp<span class="nt">&lt;/result&gt;</span>
+            <span class="nt">&lt;result</span> <span class="na">name=</span><span class="s">"cancel"</span> <span class="na">type=</span><span class="s">"redirectAction"</span><span class="nt">&gt;</span>Welcome<span class="nt">&lt;/result&gt;</span>
+            <span class="nt">&lt;result</span> <span class="na">type=</span><span class="s">"redirectAction"</span><span class="nt">&gt;</span>MainMenu<span class="nt">&lt;/result&gt;</span>
+            <span class="nt">&lt;result</span> <span class="na">name=</span><span class="s">"expired"</span> <span class="na">type=</span><span class="s">"chain"</span><span class="nt">&gt;</span>ChangePassword<span class="nt">&lt;/result&gt;</span>
+        <span class="nt">&lt;/action&gt;</span>
+
+        <span class="nt">&lt;action</span> <span class="na">name=</span><span class="s">"Logoff"</span> <span class="na">class=</span><span class="s">"mailreader2.Logoff"</span><span class="nt">&gt;</span>
+            <span class="nt">&lt;result</span> <span class="na">type=</span><span class="s">"redirectAction"</span><span class="nt">&gt;</span>Welcome<span class="nt">&lt;/result&gt;</span>
+        <span class="nt">&lt;/action&gt;</span>
+    <span class="nt">&lt;/package&gt;</span>
+<span class="nt">&lt;/struts&gt;</span>
 </code></pre>
 </div>
 
-<p>(light-on) The framework provides general-purpose defaults, so we can start using Struts right away, “out of the box”. Any factory defaults can be overridden in an application’s configuration, as needed.</p>
+<blockquote>
+  <p>The framework provides general-purpose defaults, so we can start using Struts right away, “out of the box”. 
+Any factory defaults can be overridden in an application’s configuration, as needed.</p>
+</blockquote>
 
-<p>####Struts MVC in a Nutshell####</p>
+<h2 id="struts-mvc-in-a-nutshell">Struts MVC in a Nutshell</h2>
 
-<p>Struts is a <a href="http://struts\.apache\.org/primer\.html\#mvc">Model View Controller</a>^[http://struts.apache.org/primer.html#mvc] framework. Struts provides Controller and View components, and integrates with other technologies to provide the Model. The framework’s Controller acts as a bridge between the application’s Model and the web View.</p>
+<p>Struts is a <a href="../primer.html#mvc">Model View Controller</a> framework. Struts provides Controller and View components, 
+and integrates with other technologies to provide the Model. The framework’s Controller acts as a bridge between 
+the application’s Model and the web View.</p>
 
-<p>To make it easier to present dynamic data, the framework includes a library of markup tags. The tags interact with the framework’s validation and internationalization features, to ensure that input is correct and output is localized. The tag library can be used with JSP, FreeMarker, or Velocity. Of course, other tag libraries, JSTL, and AJAX can also be used, with or without the Struts tags. JavaServer Faces components are also supported.</p>
+<p>To make it easier to present dynamic data, the framework includes a library of markup tags. The tags interact with 
+the framework’s validation and internationalization features, to ensure that input is correct and output is localized. 
+The tag library can be used with JSP, FreeMarker, or Velocity. Of course, other tag libraries, JSTL, and AJAX can also 
+be used, with or without the Struts tags. JavaServer Faces components are also supported.</p>
 
-<p>When a request is received, the Controller invokes an Action class. The Action class examines or updates the application’s state by consulting the Model (or, preferably, an interface representing the Model). To transfer data between the Model and the View, properties can be placed on the Action class, or on a plain old JavaBean.</p>
+<p>When a request is received, the Controller invokes an Action class. The Action class examines or updates 
+the application’s state by consulting the Model (or, preferably, an interface representing the Model). To transfer 
+data between the Model and the View, properties can be placed on the Action class, or on a plain old JavaBean.</p>
 
-<p>Most often, the Model is represented as a graph of JavaBean objects. The Model should do the “heavy lifting”, and the Action will act as a “traffic cop” or adapter. The framework provides sophisticated, automatic type conversion to simplify transfering data between rich domain objects and text-only HTTP requests.</p>
+<p>Most often, the Model is represented as a graph of JavaBean objects. The Model should do the “heavy lifting”, 
+and the Action will act as a “traffic cop” or adapter. The framework provides sophisticated, automatic type conversion 
+to simplify transferring data between rich domain objects and text-only HTTP requests.</p>
 
-<p>Struts is extensible. <em>Very</em>  extensible. Every class deployed by the framework is based on an interface. We provide all the base classes an application may ever need, but if we missed something, it’s easy to add your own. We provide the general-purpose framework, but you can still write <em>your</em>  application <em>your</em>  way.</p>
+<p>Struts is extensible. <em>Very</em>  extensible. Every class deployed by the framework is based on an interface. We provide 
+all the base classes an application may ever need, but if we missed something, it’s easy to add your own. We provide 
+the general-purpose framework, but you can still write <em>your</em>  application <em>your</em>  way.</p>
 
-<p>####Is Struts the best choice for every project?####</p>
+<h2 id="is-struts-the-best-choice-for-every-project">Is Struts the best choice for every project?</h2>
 
-<p>Apache Struts 2 helps you create an extensible development environment for enterprise-grade applications, based on industry standards and proven design patterns. If you need to write a very simple application, with a handful of pages, then you might consider a “Model 1” solution that uses only server pages.</p>
+<p>Apache Struts 2 helps you create an extensible development environment for enterprise-grade applications, based on 
+industry standards and proven design patterns. If you need to write a very simple application, with a handful of pages, 
+then you might consider a “Model 1” solution that uses only server pages.</p>
 
-<p>But, if you are writing a more complicated application, with dozens of pages, that need to be maintained over time, then Struts can help. For more about whether Model 1 or MVC/Model 2 is right for you, see <a href="http://www\.javaworld\.com/javaworld/jw\-12\-1999/jw\-12\-ssj\-jspmvc\.html">Understanding JavaServer Pages Model 2 architecture</a>^[http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html].</p>
+<p>But, if you are writing a more complicated application, with dozens of pages, that need to be maintained over time, 
+then Struts can help. For more about whether Model 1 or MVC/Model 2 is right for you, 
+see <a href="http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html">Understanding JavaServer Pages Model 2 architecture</a>.</p>
 
-<p>####Platform Requirements####</p>
+<h2 id="platform-requirements">Platform Requirements</h2>
 
 <p>Struts 2 requires</p>
 
 <ul>
-  <li>
-    <p>Servlet API 2.4</p>
-  </li>
-  <li>
-    <p>JSP API 2.0</p>
-  </li>
-  <li>
-    <p>Java 5</p>
-  </li>
+  <li>Servlet API 2.4</li>
+  <li>JSP API 2.0</li>
+  <li>Java 7</li>
 </ul>
 
-<p>For a full list of requirements, including dependencies used by optional plugins, see <a href="http://struts\.apache\.org/2\.x/struts2\-core/dependencies\.html">Project Dependencies</a>^[http://struts.apache.org/2.x/struts2-core/dependencies.html]</p>
-
-<p>(ok)  An alternate set of JARs for Java 4 are also available. See the “J4” distribution.</p>
-
+<p>For a full list of requirements, including dependencies used by optional plugins, see <a href="../maven/dependencies.html">Project Dependencies</a>.</p>
 
   </section>
 </article>



Mime
View raw message