struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1009571 [3/3] - /websites/production/struts/content/getting-started/
Date Sun, 02 Apr 2017 09:12:56 GMT
Modified: websites/production/struts/content/getting-started/themes.html
==============================================================================
--- websites/production/struts/content/getting-started/themes.html (original)
+++ websites/production/struts/content/getting-started/themes.html Sun Apr  2 09:12:56 2017
@@ -125,35 +125,17 @@
 
 <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><strong>Introduction</strong></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>The <a href="http://struts.apache.org/mail.html">Struts 2 user mailing list</a>
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.</p>
 
 <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;
-
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;s:select</span>
<span class="na">key=</span><span class="s">"personBean.sport"</span>
<span class="na">list=</span><span class="s">"sports"</span> <span
class="nt">/&gt;</span>
 </code></pre>
 </div>
 
@@ -161,27 +143,26 @@
 
 <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;
-
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;tr&gt;</span>
+<span class="nt">&lt;td</span> <span class="na">class=</span><span
class="s">"tdLabel"</span><span class="nt">&gt;</span>
+<span class="nt">&lt;label</span> <span class="na">for=</span><span
class="s">"save_personBean_sport"</span> <span class="na">class=</span><span
class="s">"label"</span><span class="nt">&gt;</span>Favorite sport:<span
class="nt">&lt;/label&gt;</span>
+<span class="nt">&lt;/td&gt;</span>
+<span class="nt">&lt;td&gt;</span>
+<span class="nt">&lt;select</span> <span class="na">name=</span><span
class="s">"personBean.sport"</span> <span class="na">id=</span><span
class="s">"save_personBean_sport"</span><span class="nt">&gt;</span>
+    <span class="nt">&lt;option</span> <span class="na">value=</span><span
class="s">"football"</span><span class="nt">&gt;</span>football<span
class="nt">&lt;/option&gt;</span>
+    <span class="nt">&lt;option</span> <span class="na">value=</span><span
class="s">"baseball"</span><span class="nt">&gt;</span>baseball<span
class="nt">&lt;/option&gt;</span>
+    <span class="nt">&lt;option</span> <span class="na">value=</span><span
class="s">"basketball"</span> <span class="na">selected=</span><span
class="s">"selected"</span><span class="nt">&gt;</span>basketball<span
class="nt">&lt;/option&gt;</span>
+<span class="nt">&lt;/select&gt;</span>
+<span class="nt">&lt;/td&gt;</span>
+<span class="nt">&lt;/tr&gt;</span>
 </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><strong>Specifying The Theme Struts 2 Should Use</strong></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>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 <a href="//struts.apache.org/docs/themes-and-templates.html">Themes
and Templates Documentation</a> . This tutorial will review the xhtml, css_xhtml, and
the simple themes. The ajax theme is a special theme used for ajax operations (see <a href="http://struts.apache.org/docs/ajax-theme.html">Ajax
Theme in the documentation</a> ).</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>
 
@@ -205,11 +186,11 @@
     <p>The application-scoped attribute named “theme”</p>
   </li>
   <li>
-    <p>The struts.ui.theme property in struts.properties (defaults to xhtml)</p>
+    <p>The <code class="highlighter-rouge">struts.ui.theme</code> property
in <code class="highlighter-rouge">struts.properties</code> (defaults to xhtml)</p>
   </li>
 </ol>
 
-<p>Consult <em>Selecting Themes</em>  for how to set the theme using the
above approaches.</p>
+<p>Consult <a href="//struts.apache.org/docs/selecting-themes.html">Selecting
Themes</a> 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>
 
@@ -217,41 +198,39 @@
 
 <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><strong>Specifying The CSS Used By The Struts 2 Tag</strong></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>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
<code class="highlighter-rouge">s:head</code> tag to <code class="highlighter-rouge">edit.jsp</code>.</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; }
-
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nc">.label</span>
<span class="p">{</span><span class="nl">font-style</span><span
class="p">:</span><span class="nb">italic</span><span class="p">;</span>
<span class="p">}</span>
+<span class="nc">.errorLabel</span> <span class="p">{</span><span
class="nl">font-style</span><span class="p">:</span><span class="nb">italic</span><span
class="p">;</span> <span class="nl">color</span><span class="p">:</span><span
class="no">red</span><span class="p">;</span> <span class="p">}</span>
+<span class="nc">.errorMessage</span> <span class="p">{</span><span
class="nl">font-weight</span><span class="p">:</span><span class="nb">bold</span><span
class="p">;</span> <span class="nl">color</span><span class="p">:</span><span
class="no">red</span><span class="p">;</span> <span class="p">}</span>
+<span class="nc">.checkboxLabel</span> <span class="p">{}</span>
+<span class="nc">.checkboxErrorLabel</span> <span class="p">{</span><span
class="nl">color</span><span class="p">:</span><span class="no">red</span><span
class="p">;</span> <span class="p">}</span>
+<span class="nc">.required</span> <span class="p">{</span><span
class="nl">color</span><span class="p">:</span><span class="no">red</span><span
class="p">;}</span>
+<span class="nc">.tdLabel</span> <span class="p">{</span><span
class="nl">text-align</span><span class="p">:</span><span class="nb">right</span><span
class="p">;</span> <span class="nl">vertical-align</span><span class="p">:</span><span
class="nb">top</span><span class="p">;</span> <span class="p">}</span>
 </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>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 <code class="highlighter-rouge">edit.jsp</code>.</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;
-
+<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt">&lt;style
</span><span class="na">type=</span><span class="s">"text/css"</span><span
class="nt">&gt;</span>
+    <span class="nc">.label</span> <span class="p">{</span><span
class="nl">color</span><span class="p">:</span><span class="no">blue</span><span
class="p">;</span> <span class="nl">font-style</span><span class="p">:</span><span
class="nb">normal</span><span class="p">;</span> <span class="nl">font-weight</span><span
class="p">:</span><span class="nb">bold</span><span class="p">}</span>
+<span class="nt">&lt;/style&gt;</span>
 </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><strong>Creating And Applying Your Own Themes For Struts 2 Tags</strong></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>
 
@@ -261,55 +240,38 @@
 
 <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 I’ve extended the default XHMTL theme (see file
<code class="highlighter-rouge">theme.properties</code> 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>I then modified the <code class="highlighter-rouge">checkboxlist.ftl</code>
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;
+<pre><code class="language-ftl">&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>Then in the example application I created a KUTheme_simple folder under <code
class="highlighter-rouge">src/main/resources/template</code> (optionally you can
place it under <code class="highlighter-rouge">webapp</code>, e.g. <code class="highlighter-rouge">src/main/webapp/template</code>
). In that folder I created checkboxlist.ftl and copied the contents from <code class="highlighter-rouge">template.simple</code>
<code class="highlighter-rouge">checkboxlist.ftl</code> (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>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 <code class="highlighter-rouge">struts.xml</code> 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>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 <code class="highlighter-rouge">checkboxlist.ftl</code> file
that is in the KUTheme_simple folder instead of the one in the <code class="highlighter-rouge">template.simple</code>
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><strong>Summary</strong></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>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. <code
class="highlighter-rouge">select.ftl</code>) 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>
+<p>To learn more about how to use the Struts 2 themes and how you can override them,
visit <a href="//struts.apache.org/docs/themes-and-templates.html">Themes and Templates
Documentation</a> .</p>
 
   </section>
 </article>

Modified: websites/production/struts/content/getting-started/wildcard-method-selection.html
==============================================================================
--- websites/production/struts/content/getting-started/wildcard-method-selection.html (original)
+++ websites/production/struts/content/getting-started/wildcard-method-selection.html Sun
Apr  2 09:12:56 2017
@@ -125,71 +125,50 @@
 
 <p>The example code for this tutorial, wildcard_method_selection, 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><strong>Introduction</strong></p>
 
 <p>In this tutorial we’ll cover how to configure an action node in the struts.xml
configuration file so that one action node can be used to relate several different Action
URLs to specific methods of the Action class. This will reduce the number of action nodes
we must write in the struts.xml configuration file.</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>The <a href="http://struts.apache.org/mail.html">Struts 2 user mailing list</a>
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.</p>
 
-<p>#####Example Application#####</p>
+<p><strong>Example Application</strong></p>
 
 <p><img src="attachments/att21921805_Screen shot 2010-05-30 at 8.51.40 AM.png" alt="Screen
shot 2010-05-30 at 8.51.40 AM.png" /></p>
 
-<p>The example application that supports this tutorial shows how to use Struts 2’s
wildcard method selection methodology. The example application is just a simple one that lists
some people and lets you edit them, delete them, and add a new person to the list. Everything
that the application needs to do with a Person (the model class) is controlled by the Struts
2 ActionSupport class PersonAction. The PersonAction class has several different methods (e.g.
create, edit, delete) that are called depending on what the user wants to do.</p>
+<p>The example application that supports this tutorial shows how to use Struts 2’s
wildcard method selection methodology. The example application is just a simple one that lists
some people and lets you edit them, delete them, and add a new person to the list. Everything
that the application needs to do with a <code class="highlighter-rouge">Person</code>
(the model class) is controlled by the Struts 2 <code class="highlighter-rouge">ActionSupport</code>
class <code class="highlighter-rouge">PersonAction</code>. The <code class="highlighter-rouge">PersonAction</code>
class has several different methods (e.g. create, edit, delete) that are called depending
on what the user wants to do.</p>
 
-<p>#####Wildcard Method Selection#####</p>
+<p><strong>Wildcard Method Selection</strong></p>
 
 <p>Without using the wildcard method selection technique, I’d have to write an
action mapping node in the Struts 2 configuration file for each separate action I’d want
to call. For example:</p>
 
 <p><strong>Struts.xml Action Configuration</strong></p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>&lt;action
name="createPerson" class="org.apache.struts.tutorials.wildcardmethod.action.PersonAction"
method="create"&gt;
-  &lt;result name="input"&gt;input.jsp&lt;/result&gt;
-  &lt;result name="success"&gt;view.jsp&lt;/result&gt;
-&lt;/action&gt;
-
-&lt;action name="editPerson" class="org.apache.struts.tutorials.wildcardmethod.action.PersonAction"
method="edit"&gt;
-  &lt;result name="input"&gt;input.jsp&lt;/result&gt;
-  &lt;result name="success"&gt;view.jsp&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">"createPerson"</span>
<span class="na">class=</span><span class="s">"org.apache.struts.tutorials.wildcardmethod.action.PersonAction"</span>
<span class="na">method=</span><span class="s">"create"</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>input.jsp<span
class="nt">&lt;/result&gt;</span>
+    <span class="nt">&lt;result</span> <span class="na">name=</span><span
class="s">"success"</span><span class="nt">&gt;</span>view.jsp<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">"editPerson"</span> <span class="na">class=</span><span
class="s">"org.apache.struts.tutorials.wildcardmethod.action.PersonAction"</span>
<span class="na">method=</span><span class="s">"edit"</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>input.jsp<span
class="nt">&lt;/result&gt;</span>
+    <span class="nt">&lt;result</span> <span class="na">name=</span><span
class="s">"success"</span><span class="nt">&gt;</span>view.jsp<span
class="nt">&lt;/result&gt;</span>
+<span class="nt">&lt;/action&gt;</span>
 </code></pre>
 </div>
 
 <p>So even for this simple application, I’d have to write four separate action
mapping nodes (create, edit, delete, saveOrUpdate) in the configuration file. So you can easily
see that a more complex application can have dozens of action mapping nodes.</p>
 
-<p>To implement the wildcard method selection technique to enable the Struts 2 framework
to dynamically select the correct method to call at runtime you just need to use the wildcard
character, *, in your name value and an attribute value place holder ( {1} ) for the method
value. For example:</p>
+<p>To implement the wildcard method selection technique to enable the Struts 2 framework
to dynamically select the correct method to call at runtime you just need to use the wildcard
character, *, in your name value and an attribute value place holder ( <code class="highlighter-rouge"><span
class="p">{</span><span class="err">1</span><span class="p">}</span></code>
) for the method value. For example:</p>
 
 <p><strong>Struts.xml Action Configuration Using Wildcard Method Selection</strong></p>
 
-<div class="highlighter-rouge"><pre class="highlight"><code>&lt;action
name="*Person" class="org.apache.struts.tutorials.wildcardmethod.action.PersonAction" method="{1}"&gt;
-  &lt;result name="success"&gt;view.jsp&lt;/result&gt;
-  &lt;result name="input"&gt;input.jsp&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">"*Person"</span> <span
class="na">class=</span><span class="s">"org.apache.struts.tutorials.wildcardmethod.action.PersonAction"</span>
<span class="na">method=</span><span class="s">"{1}"</span><span
class="nt">&gt;</span>
+    <span class="nt">&lt;result</span> <span class="na">name=</span><span
class="s">"success"</span><span class="nt">&gt;</span>view.jsp<span
class="nt">&lt;/result&gt;</span>
+    <span class="nt">&lt;result</span> <span class="na">name=</span><span
class="s">"input"</span><span class="nt">&gt;</span>input.jsp<span
class="nt">&lt;/result&gt;</span>
+<span class="nt">&lt;/action&gt;</span>
 </code></pre>
 </div>
 
-<p>The * is the wildcard character. Any action name values that end in “Person”
will be handled by this action mapping. Whatever value is before “Person” will be
the value used for the method attribute (the {1} place holder will be replaced with that value).
For example this URL:</p>
+<p>The <code class="highlighter-rouge">*</code> is the wildcard character.
Any action name values that end in “Person” will be handled by this action mapping.
Whatever value is before “Person” will be the value used for the method attribute
(the <code class="highlighter-rouge"><span class="p">{</span><span class="err">1</span><span
class="p">}</span></code> place holder will be replaced with that value). For
example this URL:</p>
 
 <p><a href="http://localhost:8080/wildcard-method-selection/createPerson.action">http://localhost:8080/wildcard-method-selection/createPerson.action</a></p>
 
@@ -197,21 +176,21 @@
 
 <p><a href="http://localhost:8080/wildcard-method-selection/deletePerson.action">http://localhost:8080/wildcard-method-selection/deletePerson.action</a></p>
 
-<p>will cause the delete method of class PersonAction to be called.</p>
+<p>will cause the delete method of class <code class="highlighter-rouge">PersonAction</code>
to be called.</p>
 
 <p>What happens if we have a URL with nothing in front of Person? For example:</p>
 
 <p><a href="http://localhost:8080/wildcard-method-selection/Person.action">http://localhost:8080/wildcard-method-selection/Person.action</a></p>
 
-<p>If there is no value in front of Person, then the Struts 2 framework will call the
execute method of the class PersonAction.</p>
+<p>If there is no value in front of Person, then the Struts 2 framework will call the
execute method of the class <code class="highlighter-rouge">PersonAction</code>.</p>
 
-<p>#####Dynamic Method Invocation#####</p>
+<p><strong>Dynamic Method Invocation</strong></p>
 
-<p>The wildcard method selection technique explained above should not be confused with
the “Dynamic Method Invocation” technique. The Struts 2 documentation explains this
technique (which uses the bang, !, operator in the action name) and recommends against using
the “Dynamic Method Invocation” technique due to security and other reasons related
to how this technique is implemented internally.</p>
+<p>The wildcard method selection technique explained above should not be confused with
the “Dynamic Method Invocation” technique. The Struts 2 documentation explains this
technique (which uses the bang, <code class="highlighter-rouge">!</code>, operator
in the action name) and recommends against using the “Dynamic Method Invocation”
technique due to security and other reasons related to how this technique is implemented internally.</p>
 
-<p>The Struts 2 documentation also recommends turning off the option to use the dynamic
method invocation by setting struts.enable.DynamicMethodInvocation to FALSE in the Struts
configuration.</p>
+<p>The Struts 2 documentation also recommends turning off the option to use the dynamic
method invocation by setting <code class="highlighter-rouge">struts.enable.DynamicMethodInvocation</code>
to <code class="highlighter-rouge">FALSE</code> in the Struts configuration.</p>
 
-<p>#####Summary#####</p>
+<p><strong>Summary</strong></p>
 
 <p>By using the wildcard method selection technique explained above, you can significantly
reduce the number of action mapping nodes you need to write and manage in the Struts 2 XML
configuration file.</p>
 



Mime
View raw message