Updates production by Jenkins
Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/f694fc8f Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/f694fc8f Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/f694fc8f Branch: refs/heads/asf-site Commit: f694fc8f7c17f4ff2864319dd71699a1b6eddb01 Parents: 68ba32a Author: jenkins <bui...@apache.org> Authored: Fri Aug 25 12:18:44 2017 +0000 Committer: jenkins <bui...@apache.org> Committed: Fri Aug 25 12:18:44 2017 +0000 ---------------------------------------------------------------------- ...ing-application-session-request-objects.html | 119 +-- content/core-developers/action-chaining.html | 87 ++- .../core-developers/action-event-listener.html | 42 +- .../action-mapper-and-action-mapping.html | 45 +- .../action-proxy-and-actionproxy-factory.html | 102 ++- content/core-developers/default-properties.html | 225 +++++- .../core-developers/dispatcher-listener.html | 36 +- .../formatting-dates-and-numbers.html | 86 +-- content/core-developers/index.html | 4 +- content/core-developers/interceptors.html | 398 +++++++++- content/core-developers/localization.html | 311 ++------ content/core-developers/logging.html | 136 ++-- .../model-driven-interceptor.html | 143 +--- .../core-developers/parameters-interceptor.html | 281 +++---- .../core-developers/pre-result-listener.html | 76 +- content/core-developers/result-types.html | 115 ++- content/core-developers/static-content.html | 105 +-- content/core-developers/struts-default-xml.html | 470 ++++++++++-- content/core-developers/type-conversion.html | 677 +++++++---------- content/core-developers/validation.html | 729 ++++++++++--------- .../core-developers/writing-interceptors.html | 112 ++- 21 files changed, 2329 insertions(+), 1970 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-site/blob/f694fc8f/content/core-developers/accessing-application-session-request-objects.html ---------------------------------------------------------------------- diff --git a/content/core-developers/accessing-application-session-request-objects.html b/content/core-developers/accessing-application-session-request-objects.html index 28d2209..dda22a7 100644 --- a/content/core-developers/accessing-application-session-request-objects.html +++ b/content/core-developers/accessing-application-session-request-objects.html @@ -131,133 +131,58 @@ <p>The framework provides several access helpers to access Session, Application, Request scopes.</p> -<p>####Accessing from Java####</p> +<h2 id="accessing-from-java">Accessing from Java</h2> -<p>All the JEE scope attribute maps can be accessed via</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>ActionContext -</code></pre> -</div> -<p>.</p> +<p>All the JEE scope attribute maps can be accessed via <code class="highlighter-rouge">ActionContext</code>.</p> <p><strong>Accessing servlet scopes</strong></p> -<div class="highlighter-rouge"><pre class="highlight"><code> -Map attr = (Map) ActionContext.getContext().get("attr"); -attr.put("myId",myProp); - -Map application = (Map) ActionContext.getContext().get("application"); -application.put("myId",myProp); +<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">Map</span> <span class="n">attr</span> <span class="o">=</span> <span class="o">(</span><span class="n">Map</span><span class="o">)</span> <span class="n">ActionContext</span><span class="o">.</span><span class="na">getContext</span><span class="o">().</span><span class="na">get</span><span class="o">(</span><span class="s">"attr"</span><span class="o">);</span> +<span class="n">attr</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"myId"</span><span class="o">,</span><span class="n">myProp</span><span class="o">);</span> -Map session = (Map) ActionContext.getContext().get("session"); -session.put("myId", myProp); +<span class="n">Map</span> <span class="n">application</span> <span class="o">=</span> <span class="o">(</span><span class="n">Map</span><span class="o">)</span> <span class="n">ActionContext</span><span class="o">.</span><span class="na">getContext</span><span class="o">().</span><span class="na">get</span><span class="o">(</span><span class="s">"application"</span><span class="o">);</span> +<span class="n">application</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"myId"</span><span class="o">,</span><span class="n">myProp</span><span class="o">);</span> -Map request = (Map) ActionContext.getContext().get("request"); -request.put("myId",myProp); +<span class="n">Map</span> <span class="n">session</span> <span class="o">=</span> <span class="o">(</span><span class="n">Map</span><span class="o">)</span> <span class="n">ActionContext</span><span class="o">.</span><span class="na">getContext</span><span class="o">().</span><span class="na">get</span><span class="o">(</span><span class="s">"session"</span><span class="o">);</span> +<span class="n">session</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"myId"</span><span class="o">,</span> <span class="n">myProp</span><span class="o">);</span> +<span class="n">Map</span> <span class="n">request</span> <span class="o">=</span> <span class="o">(</span><span class="n">Map</span><span class="o">)</span> <span class="n">ActionContext</span><span class="o">.</span><span class="na">getContext</span><span class="o">().</span><span class="na">get</span><span class="o">(</span><span class="s">"request"</span><span class="o">);</span> +<span class="n">request</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"myId"</span><span class="o">,</span><span class="n">myProp</span><span class="o">);</span> </code></pre> </div> <blockquote> - -</blockquote> - -<blockquote> - -</blockquote> - -<blockquote> - <p>Do not use ActionContext.getContext() in the constructor of your Action class. The values may not be set up, and the call may return null for getSession().</p> -</blockquote> - -<blockquote> - + <p>Do not use <code class="highlighter-rouge">ActionContext.getContext()</code> in the constructor of your Action class. The values may not be set up, and +the call may return null for getSession().</p> </blockquote> -<p>We can also access the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>HttpServletRequest -</code></pre> -</div> -<p>and</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>HttpServletResponse -</code></pre> -</div> -<p>objects themselves through</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>ServletActionContext -</code></pre> -</div> -<p>. In general this isnât recommended as it will tie our action to the servlet specification.</p> +<p>We can also access the <code class="highlighter-rouge">HttpServletRequest</code> and <code class="highlighter-rouge">HttpServletResponse</code> objects themselves through <code class="highlighter-rouge">ServletActionContext</code>. +In general this isnât recommended as it will tie our action to the servlet specification.</p> <p><strong>Setting session attribute through session object</strong></p> -<div class="highlighter-rouge"><pre class="highlight"><code> -ServletActionContext.getRequest().getSession().put("myId", myProp); - +<div class="highlighter-rouge"><pre class="highlight"><code><span class="n">ServletActionContext</span><span class="o">.</span><span class="na">getRequest</span><span class="o">().</span><span class="na">getSession</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"myId"</span><span class="o">,</span> <span class="n">myProp</span><span class="o">);</span> </code></pre> </div> -<p>Implementing</p> +<p>Implementing <code class="highlighter-rouge">ServletRequestAware</code> or <code class="highlighter-rouge">ServletResponseAware</code>, combined with the <code class="highlighter-rouge">servletConfig</code> interceptor, +is an alternative way to access the request and response objects, with the same caveat.</p> -<div class="highlighter-rouge"><pre class="highlight"><code>ServletRequestAware -</code></pre> -</div> -<p>or</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>ServletResponseAware -</code></pre> -</div> -<p>, combined with the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>"servletConfig" interceptor -</code></pre> -</div> -<p>, is an alternative way to access the request and response objects, with the same caveat.</p> - -<p>####Accessing from the view (JSP, FreeMarker, etc.)####</p> - -<p>Request and session attributes are accessed via OGNL using the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>#session -</code></pre> -</div> -<p>and</p> +<h2 id="accessing-from-the-view-jsp-freemarker-etc">Accessing from the view (JSP, FreeMarker, etc.)</h2> -<div class="highlighter-rouge"><pre class="highlight"><code>#request -</code></pre> -</div> -<p>stack values.</p> +<p>Request and session attributes are accessed via OGNL using the <code class="highlighter-rouge">#session</code> and <code class="highlighter-rouge">#request</code> stack values.</p> -<p>The</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>#attr -</code></pre> -</div> -<p>stack value will search the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>javax.servlet.jsp.PageContext -</code></pre> -</div> -<p>for the specified key. If the</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>PageContext -</code></pre> -</div> -<p>doeanât exist, it will search the request, session, and application scopes, in that order.</p> +<p>The <code class="highlighter-rouge">#attr</code> stack value will search the <code class="highlighter-rouge">javax.servlet.jsp.PageContext</code> for the specified key. If the <code class="highlighter-rouge">PageContext</code> +doeanât exist, it will search the request, session, and application scopes, in that order.</p> <p><strong>Accessing the Session or Request from a JSP</strong></p> -<div class="highlighter-rouge"><pre class="highlight"><code> -<s:property value="#session.myId" /> +<pre><code class="language-jsp"><s:property value="#session.myId" /> <s:property value="#request.myId" /> <s:property value="#attr.myId" /> - </code></pre> -</div> </section> </article> http://git-wip-us.apache.org/repos/asf/struts-site/blob/f694fc8f/content/core-developers/action-chaining.html ---------------------------------------------------------------------- diff --git a/content/core-developers/action-chaining.html b/content/core-developers/action-chaining.html index 293fc7d..6051b14 100644 --- a/content/core-developers/action-chaining.html +++ b/content/core-developers/action-chaining.html @@ -127,44 +127,71 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/action-chaining.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="action-chaining">Action Chaining</h1> -<p>The framework provides the ability to chain multiple actions into a defined sequence or workflow. This feature works by applying a <a href="chain-result.html">Chain Result</a> to a given Action, and intercepting its target Actionâs invocation with a <a href="chaining-interceptor.html">Chaining Interceptor</a>.</p> - -<table> - <tbody> - <tr> - <td>As a rule, Action Chaining is not recommended. First explore other options, such as the <em>Redirect After Post</em> technique.</td> - </tr> - </tbody> -</table> - -<table> - <tbody> - <tr> - </tr> - </tbody> -</table> - -<p>####Chain Result####</p> - -<p>The <a href="chain-result.html">Chain Result</a> is a result type that invokes an Action with its own Interceptor Stack and Result. This Interceptor allows an Action to forward requests to a target Action, while propagating the state of the source Action. Below is an example of how to define this sequence.</p> - -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=example|lang=xml|javadoc=true|url=com.opensymphony.xwork2.ActionChainResult</span><span class="p">}</span><span class="w"> -</span></code></pre> +<p>The framework provides the ability to chain multiple actions into a defined sequence or workflow. This feature works +by applying a <a href="chain-result.html">Chain Result</a> to a given Action, and intercepting its target Actionâs invocation +with a <a href="chaining-interceptor.html">Chaining Interceptor</a>.</p> + +<blockquote> + <p>As a rule, Action Chaining is not recommended. First explore other options, such as the <code class="highlighter-rouge">Redirect After Post</code> technique.</p> +</blockquote> + +<h2 id="chain-result">Chain Result</h2> + +<p>The <a href="chain-result.html">Chain Result</a> is a result type that invokes an Action with its own Interceptor Stack and Result. +This Interceptor allows an Action to forward requests to a target Action, while propagating the state of the source Action. +Below is an example of how to define this sequence.</p> + +<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt"><package</span> <span class="na">name=</span><span class="s">"public"</span> <span class="na">extends=</span><span class="s">"struts-default"</span><span class="nt">></span> + <span class="c"><!-- Chain creatAccount to login, using the default parameter --></span> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"createAccount"</span> <span class="na">class=</span><span class="s">"..."</span><span class="nt">></span> + <span class="nt"><result</span> <span class="na">type=</span><span class="s">"chain"</span><span class="nt">></span>login<span class="nt"></result></span> + <span class="nt"></action></span> + + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"login"</span> <span class="na">class=</span><span class="s">"..."</span><span class="nt">></span> + <span class="c"><!-- Chain to another namespace --></span> + <span class="nt"><result</span> <span class="na">type=</span><span class="s">"chain"</span><span class="nt">></span> + <span class="nt"><param</span> <span class="na">name=</span><span class="s">"actionName"</span><span class="nt">></span>dashboard<span class="nt"></param></span> + <span class="nt"><param</span> <span class="na">name=</span><span class="s">"namespace"</span><span class="nt">></span>/secure<span class="nt"></param></span> + <span class="nt"></result></span> + <span class="nt"></action></span> +<span class="nt"></package></span> + +<span class="nt"><package</span> <span class="na">name=</span><span class="s">"secure"</span> <span class="na">extends=</span><span class="s">"struts-default"</span> <span class="na">namespace=</span><span class="s">"/secure"</span><span class="nt">></span> + <span class="nt"><action</span> <span class="na">name=</span><span class="s">"dashboard"</span> <span class="na">class=</span><span class="s">"..."</span><span class="nt">></span> + <span class="nt"><result></span>dashboard.jsp<span class="nt"></result></span> + <span class="nt"></action></span> +<span class="nt"></package></span> +</code></pre> </div> -<p>Another action mapping in the same namespace (or the default ââ namespace) can be executed after this action mapping (see <a href="configuration-files.html">Configuration Files</a>). An optional ânamespaceâ parameter may also be added to specify an action in a different namespace.</p> +<p>Another action mapping in the same namespace (or the default ââ namespace) can be executed after this action mapping +(see <a href="configuration-files.html">Configuration Files</a>). An optional ânamespaceâ parameter may also be added to specify +an action in a different namespace.</p> -<p>####Chaining Interceptor####</p> +<h2 id="chaining-interceptor">Chaining Interceptor</h2> -<p>If you need to copy the properties from your previous Actions in the chain to the current action, you should apply the <a href="chaining-interceptor.html">Chaining Interceptor</a>. The Interceptor will copy the original parameters from the request, and the ValueStack is passed in to the target Action. The source Action is remembered by the ValueStack, allowing the target Action to access the properties of the preceding Action(s) using the ValueStack, and also makes these properties available to the final result of the chain, such as the JSP or Velocity page.</p> +<p>If you need to copy the properties from your previous Actions in the chain to the current action, you should apply +the <a href="chaining-interceptor.html">Chaining Interceptor</a>. The Interceptor will copy the original parameters from the request, +and the ValueStack is passed in to the target Action. The source Action is remembered by the ValueStack, allowing +the target Action to access the properties of the preceding Action(s) using the ValueStack, and also makes these +properties available to the final result of the chain, such as the JSP or Velocity page.</p> -<p>One common use of Action chaining is to provide lookup lists (like for a dropdown list of states). Since these Actions get put on the ValueStack, their properties will be available in the view. This functionality can also be done using the ActionTag to execute an Action from the display page. You may also use the <a href="redirect-action-result.html">Redirect Action Result</a> to accomplish this.</p> +<p>One common use of Action chaining is to provide lookup lists (like for a dropdown list of states). Since these Actions +get put on the ValueStack, their properties will be available in the view. This functionality can also be done using +the ActionTag to execute an Action from the display page. You may also use +the <a href="redirect-action-result.html">Redirect Action Result</a> to accomplish this.</p> -<p>#####Use with care#####</p> +<h2 id="use-with-care">Use with care</h2> -<p>Experience shows that chaining should be used with care. If chaining is overused, an application can turn into âspaghetti codeâ. Actions should be treated as a <a href="http://martinfowler\.com/eaaCatalog/transactionScript\.html">Transaction Script</a>^[http://martinfowler.com/eaaCatalog/transactionScript.html], rather than as methods in a <a href="http://msdn2\.microsoft\.com/en\-us/library/aa291571(VS\.71)\.aspx">Business Facade</a>^[http://msdn2.microsoft.com/en-us/library/aa291571(VS.71).aspx]. Be sure to ask yourself why you need to chain from one Action to another. Is a navigational issue, or could the logic in Action2 be pushed back to a support class or business facade so that Action1 can call it too?</p> +<p>Experience shows that chaining should be used with care. If chaining is overused, an application can turn into +âspaghetti codeâ. Actions should be treated as a <a href="http://martinfowler.com/eaaCatalog/transactionScript.html">Transaction Script</a>, +rather than as methods in a <a href="http://msdn2.microsoft.com/en\-us/library/aa291571(VS.71).aspx">Business Facade</a>. Be sure +to ask yourself why you need to chain from one Action to another. Is a navigational issue, or could the logic in Action2 +be pushed back to a support class or business facade so that Action1 can call it too?</p> -<p>Ideally, Action classes should be as short as possible. All the core logic should be pushed back to a support class or a business facade, so that Actions only call methods. Actions are best used as adapters, rather than as a class where coding logic is defined.</p> +<p>Ideally, Action classes should be as short as possible. All the core logic should be pushed back to a support class +or a business facade, so that Actions only call methods. Actions are best used as adapters, rather than as a class +where coding logic is defined.</p> </section> </article> http://git-wip-us.apache.org/repos/asf/struts-site/blob/f694fc8f/content/core-developers/action-event-listener.html ---------------------------------------------------------------------- diff --git a/content/core-developers/action-event-listener.html b/content/core-developers/action-event-listener.html index b0ee42e..f7071cd 100644 --- a/content/core-developers/action-event-listener.html +++ b/content/core-developers/action-event-listener.html @@ -127,37 +127,35 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/action-event-listener.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="actioneventlistener">ActionEventListener</h1> -<p>A ActionEventListener can be used to add some logic when actionâs instance is created or when exception occurred during processing the action.</p> +<p>An <code class="highlighter-rouge">ActionEventListener</code> can be used to add some logic when actionâs instance is created or when exception occurred +during processing the action.</p> -<p>#####Configuration#####</p> +<h2 id="configuration">Configuration</h2> -<p>Right now there can be only one instance of ActionEventListener for the whole Struts2 application. You can configure it via struts.xml by adding bean definition:</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> -<bean type="com.opensymphony.xwork2.ActionEventListener" class="com.demo.MyActionEventListener"/> +<p>Right now there can be only one instance of <code class="highlighter-rouge">ActionEventListener</code> for the whole Struts2 application. You can configure +it via <code class="highlighter-rouge">struts.xml</code> by adding bean definition:</p> +<div class="highlighter-rouge"><pre class="highlight"><code><span class="nt"><bean</span> <span class="na">type=</span><span class="s">"com.opensymphony.xwork2.ActionEventListener"</span> <span class="na">class=</span><span class="s">"com.demo.MyActionEventListener"</span><span class="nt">/></span> </code></pre> </div> -<p>#####Examples#####</p> +<h2 id="examples">Examples</h2> -<div class="highlighter-rouge"><pre class="highlight"><code> -public class MyActionEventListener implements ActionEventListener { +<div class="highlighter-rouge"><pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="nc">MyActionEventListener</span> <span class="kd">implements</span> <span class="n">ActionEventListener</span> <span class="o">{</span> - public Object prepare(Object action, ValueStack stack) { - if (action instanceof MyBaseAction) { - ((MyBaseAction)action).setUserService(stack.findValue("userService")); - } - } + <span class="kd">public</span> <span class="n">Object</span> <span class="n">prepare</span><span class="o">(</span><span class="n">Object</span> <span class="n">action</span><span class="o">,</span> <span class="n">ValueStack</span> <span class="n">stack</span><span class="o">)</span> <span class="o">{</span> + <span class="k">if</span> <span class="o">(</span><span class="n">action</span> <span class="k">instanceof</span> <span class="n">MyBaseAction</span><span class="o">)</span> <span class="o">{</span> + <span class="o">((</span><span class="n">MyBaseAction</span><span class="o">)</span><span class="n">action</span><span class="o">).</span><span class="na">setUserService</span><span class="o">(</span><span class="n">stack</span><span class="o">.</span><span class="na">findValue</span><span class="o">(</span><span class="s">"userService"</span><span class="o">));</span> + <span class="o">}</span> + <span class="o">}</span> - public String handleException(Throwable t, ValueStack stack) { - if (t instanceof MyBusinessException) { - return stack.findString("defaultBusinesResult"); - } - return null; - } -} - + <span class="kd">public</span> <span class="n">String</span> <span class="n">handleException</span><span class="o">(</span><span class="n">Throwable</span> <span class="n">t</span><span class="o">,</span> <span class="n">ValueStack</span> <span class="n">stack</span><span class="o">)</span> <span class="o">{</span> + <span class="k">if</span> <span class="o">(</span><span class="n">t</span> <span class="k">instanceof</span> <span class="n">MyBusinessException</span><span class="o">)</span> <span class="o">{</span> + <span class="k">return</span> <span class="n">stack</span><span class="o">.</span><span class="na">findString</span><span class="o">(</span><span class="s">"defaultBusinesResult"</span><span class="o">);</span> + <span class="o">}</span> + <span class="k">return</span> <span class="kc">null</span><span class="o">;</span> + <span class="o">}</span> +<span class="o">}</span> </code></pre> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/f694fc8f/content/core-developers/action-mapper-and-action-mapping.html ---------------------------------------------------------------------- diff --git a/content/core-developers/action-mapper-and-action-mapping.html b/content/core-developers/action-mapper-and-action-mapping.html index bb33da8..425d7f5 100644 --- a/content/core-developers/action-mapper-and-action-mapping.html +++ b/content/core-developers/action-mapper-and-action-mapping.html @@ -127,44 +127,29 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/action-mapper-and-action-mapping.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="action-mapper--action-mapping">Action Mapper & Action Mapping</h1> -<p>The ActionMapper fetches the ActionMapping object corresponding to a given request. Essentially, the ActionMapping is a data transfer object that collects together details such as the Action class and method to execute. The mapping is utilized by the Dispatcher and various user interface components. It is customizable through</p> +<p>The ActionMapper fetches the ActionMapping object corresponding to a given request. Essentially, the ActionMapping +is a data transfer object that collects together details such as the Action class and method to execute. The mapping +is utilized by the Dispatcher and various user interface components. It is customizable through <code class="highlighter-rouge">struts.mapper.class</code> +entry in <code class="highlighter-rouge">struts.properties</code>.</p> -<div class="highlighter-rouge"><pre class="highlight"><code>struts.mapper.class -</code></pre> -</div> -<p>entry in</p> - -<div class="highlighter-rouge"><pre class="highlight"><code>struts.properties -</code></pre> -</div> -<p>.</p> - -<p>####Customize####</p> +<h2 id="customize">Customize</h2> <p>Custom ActionMapper must implement ActionMapper interface and have a default constructor.</p> -<blockquote> - -</blockquote> - -<div class="highlighter-rouge"><pre class="highlight"><code> -struts.mapper.class=foo.bar.MyCustomActionMapper - +<div class="highlighter-rouge"><pre class="highlight"><code>struts.mapper.class=foo.bar.MyCustomActionMapper </code></pre> </div> -<div class="highlighter-rouge"><pre class="highlight"><code> -public class MyCustomActionMapper implements ActionMapper { - public ActionMapping getMapping(HttpServletRequest request, - ConfigurationManager configManager) { - .... - } - - public String getUriFromActionMapping(ActionMapping mapping) { - .... - } -} +<div class="highlighter-rouge"><pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="nc">MyCustomActionMapper</span> <span class="kd">implements</span> <span class="n">ActionMapper</span> <span class="o">{</span> + <span class="kd">public</span> <span class="n">ActionMapping</span> <span class="n">getMapping</span><span class="o">(</span><span class="n">HttpServletRequest</span> <span class="n">request</span><span class="o">,</span> + <span class="n">ConfigurationManager</span> <span class="n">configManager</span><span class="o">)</span> <span class="o">{</span> + <span class="o">....</span> + <span class="o">}</span> + <span class="kd">public</span> <span class="n">String</span> <span class="n">getUriFromActionMapping</span><span class="o">(</span><span class="n">ActionMapping</span> <span class="n">mapping</span><span class="o">)</span> <span class="o">{</span> + <span class="o">....</span> + <span class="o">}</span> +<span class="o">}</span> </code></pre> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/f694fc8f/content/core-developers/action-proxy-and-actionproxy-factory.html ---------------------------------------------------------------------- diff --git a/content/core-developers/action-proxy-and-actionproxy-factory.html b/content/core-developers/action-proxy-and-actionproxy-factory.html index 4d771ce..53acfab 100644 --- a/content/core-developers/action-proxy-and-actionproxy-factory.html +++ b/content/core-developers/action-proxy-and-actionproxy-factory.html @@ -127,72 +127,70 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/action-proxy-and-actionproxy-factory.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="action-proxy--actionproxy-factory">Action Proxy & ActionProxy Factory</h1> -<p>The ActionProxy obtains the Action class and calls the appropriate method. By default, Actions are obtained through local instantiation, but an Action could also be obtained remotely if an alternative ActionProxy were provided.</p> +<p>The ActionProxy obtains the Action class and calls the appropriate method. By default, Actions are obtained through +local instantiation, but an Action could also be obtained remotely if an alternative ActionProxy were provided.</p> -<p>An alternative ActionProxy can be configured through ActionProxyFactory. Typically, an ActionProxy will utilize the ActionInvocation to encapsulate the execution of a particular request.</p> +<p>An alternative ActionProxy can be configured through ActionProxyFactory. Typically, an ActionProxy will utilize +the ActionInvocation to encapsulate the execution of a particular request.</p> -<p>The ActionInvocation determines how an Action is handled: Is it being intercepted? Is there a PreResultListener acting on it?</p> +<p>The ActionInvocation determines how an Action is handled: Is it being intercepted? Is there a PreResultListener +acting on it?</p> -<p>Essentially, ActionProxy encapsulates how an Action can be obtained. ActionInvocation encapsulates how the Action is executed when a request is invoked.</p> +<p>Essentially, ActionProxy encapsulates how an Action can be obtained. ActionInvocation encapsulates how the Action +s executed when a request is invoked.</p> -<p>####Customization####</p> +<h2 id="customization">Customization</h2> -<p>#####ActionProxyFactory#####</p> +<h3 id="actionproxyfactory">ActionProxyFactory</h3> -<div class="highlighter-rouge"><pre class="highlight"><code> - ActionProxyFactory.setFactory(new MyActionProxyFactory() { +<div class="highlighter-rouge"><pre class="highlight"><code> <span class="n">ActionProxyFactory</span><span class="o">.</span><span class="na">setFactory</span><span class="o">(</span><span class="k">new</span> <span class="n">MyActionProxyFactory</span><span class="o">()</span> <span class="o">{</span> - // Do something interesting... - - }); + <span class="c1">// Do something interesting...</span> + <span class="o">});</span> </code></pre> </div> -<p>#####ActionProxy#####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> - ActionProxyFactory.getFactory(new MyActionProxyFactory() { - .... - public ActionProxy createActionProxy(Configuration config, - String namespace, String actionName, Map extraContext) - throws Exception { - createActionProxy(config, namespace, actionName, extraContext, true); - } - public ActionProxy createActionProxy(Configuration config, - String namespace, String actionName, Map extraContext, - boolean executeResult, boolean cleanupContext) - throws Exception { - .... - } - .... - }); - +<h3 id="actionproxy">ActionProxy</h3> + +<div class="highlighter-rouge"><pre class="highlight"><code> <span class="n">ActionProxyFactory</span><span class="o">.</span><span class="na">getFactory</span><span class="o">(</span><span class="k">new</span> <span class="n">MyActionProxyFactory</span><span class="o">()</span> <span class="o">{</span> + <span class="o">....</span> + <span class="kd">public</span> <span class="n">ActionProxy</span> <span class="n">createActionProxy</span><span class="o">(</span><span class="n">Configuration</span> <span class="n">config</span><span class="o">,</span> + <span class="n">String</span> <span class="n">namespace</span><span class="o">,</span> <span class="n">String</span> <span class="n">actionName</span><span class="o">,</span> <span class="n">Map</span> <span class="n">extraContext</span><span class="o">)</span> + <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> + <span class="n">createActionProxy</span><span class="o">(</span><span class="n">config</span><span class="o">,</span> <span class="n">namespace</span><span class="o">,</span> <span class="n">actionName</span><span class="o">,</span> <span class="n">extraContext</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span> + <span class="o">}</span> + <span class="kd">public</span> <span class="n">ActionProxy</span> <span class="n">createActionProxy</span><span class="o">(</span><span class="n">Configuration</span> <span class="n">config</span><span class="o">,</span> + <span class="n">String</span> <span class="n">namespace</span><span class="o">,</span> <span class="n">String</span> <span class="n">actionName</span><span class="o">,</span> <span class="n">Map</span> <span class="n">extraContext</span><span class="o">,</span> + <span class="kt">boolean</span> <span class="n">executeResult</span><span class="o">,</span> <span class="kt">boolean</span> <span class="n">cleanupContext</span><span class="o">)</span> + <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> + <span class="o">....</span> + <span class="o">}</span> + <span class="o">....</span> + <span class="o">});</span> </code></pre> </div> -<p>#####ActionInvocation#####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> - ActionProxyFactory.getFactory(new MyActionProxyFactory() { - ... - public ActionInvocation createActionInvocation(ActionProxy actionProxy) - throws Exception { - createActionInvocation(actionProxy, new LinkedHashMap()); - } - public ActionInvocation createActionInvocation(ActionProxy actionProxy, - Map extraContext) throws Exception { - createActionInvocation(actionProxy, extraContext, true); - } - public ActionInvocation createActionInvocation(ActionProxy actionProxy, - Map extraContext, boolean pushAction) - throws Exception { - // Do implementation of ActionInvocation here - ..... - } - ... - }); - +<h3 id="actioninvocation">ActionInvocation</h3> + +<div class="highlighter-rouge"><pre class="highlight"><code> <span class="n">ActionProxyFactory</span><span class="o">.</span><span class="na">getFactory</span><span class="o">(</span><span class="k">new</span> <span class="n">MyActionProxyFactory</span><span class="o">()</span> <span class="o">{</span> + <span class="o">...</span> + <span class="kd">public</span> <span class="n">ActionInvocation</span> <span class="n">createActionInvocation</span><span class="o">(</span><span class="n">ActionProxy</span> <span class="n">actionProxy</span><span class="o">)</span> + <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> + <span class="n">createActionInvocation</span><span class="o">(</span><span class="n">actionProxy</span><span class="o">,</span> <span class="k">new</span> <span class="n">LinkedHashMap</span><span class="o">());</span> + <span class="o">}</span> + <span class="kd">public</span> <span class="n">ActionInvocation</span> <span class="n">createActionInvocation</span><span class="o">(</span><span class="n">ActionProxy</span> <span class="n">actionProxy</span><span class="o">,</span> + <span class="n">Map</span> <span class="n">extraContext</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> + <span class="n">createActionInvocation</span><span class="o">(</span><span class="n">actionProxy</span><span class="o">,</span> <span class="n">extraContext</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span> + <span class="o">}</span> + <span class="kd">public</span> <span class="n">ActionInvocation</span> <span class="n">createActionInvocation</span><span class="o">(</span><span class="n">ActionProxy</span> <span class="n">actionProxy</span><span class="o">,</span> + <span class="n">Map</span> <span class="n">extraContext</span><span class="o">,</span> <span class="kt">boolean</span> <span class="n">pushAction</span><span class="o">)</span> + <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span> + <span class="c1">// Do implementation of ActionInvocation here</span> + <span class="o">.....</span> + <span class="o">}</span> + <span class="o">...</span> + <span class="o">});</span> </code></pre> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/f694fc8f/content/core-developers/default-properties.html ---------------------------------------------------------------------- diff --git a/content/core-developers/default-properties.html b/content/core-developers/default-properties.html index 93c972d..ad14a3c 100644 --- a/content/core-developers/default-properties.html +++ b/content/core-developers/default-properties.html @@ -139,7 +139,230 @@ on the classpath, but it is typically found under <code class="highlighter-rouge <p><strong>default.properties</strong></p> -<figure class="highlight"><pre><code class="language-txt" data-lang="txt">500: Internal Server Error</code></pre></figure> +<figure class="highlight"><pre><code class="language-txt" data-lang="txt"># +# $Id$ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +### START SNIPPET: complete_file + +### Struts default properties +###(can be overridden by a struts.properties file in the root of the classpath) +### + +### This can be used to set your default locale and encoding scheme +# struts.locale=en_US +struts.i18n.encoding=UTF-8 + +### if specified, the default object factory can be overridden here +### Note: short-hand notation is supported in some cases, such as "spring" +### Alternatively, you can provide a com.opensymphony.xwork2.ObjectFactory subclass name here +# struts.objectFactory = spring + +### specifies the autoWiring logic when using the SpringObjectFactory. +### valid values are: name, type, auto, and constructor (name is the default) +struts.objectFactory.spring.autoWire = name + +### indicates to the struts-spring integration if Class instances should be cached +### this should, until a future Spring release makes it possible, be left as true +### unless you know exactly what you are doing! +### valid values are: true, false (true is the default) +struts.objectFactory.spring.useClassCache = true + +### ensures the autowire strategy is always respected. +### valid values are: true, false (false is the default) +struts.objectFactory.spring.autoWire.alwaysRespect = false + +### By default SpringObjectFactory doesn't support AOP +### This flag was added just temporally to check if nothing is broken +### See https://issues.apache.org/jira/browse/WW-4110 +struts.objectFactory.spring.enableAopSupport = false + +### if specified, the default object type determiner can be overridden here +### Note: short-hand notation is supported in some cases, such as "tiger" or "notiger" +### Alternatively, you can provide a com.opensymphony.xwork2.util.ObjectTypeDeterminer implementation name here +### Note: By default, com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer is used which handles type detection +### using generics. com.opensymphony.xwork2.util.GenericsObjectTypeDeterminer was deprecated since XWork 2, it's +### functions are integrated in DefaultObjectTypeDeterminer now. +### To disable tiger support use the "notiger" property value here. +#struts.objectTypeDeterminer = tiger +#struts.objectTypeDeterminer = notiger + +### Parser to handle HTTP POST requests, encoded using the MIME-type multipart/form-data +# struts.multipart.parser=cos +# struts.multipart.parser=pell +# struts.multipart.parser=jakarta-stream +struts.multipart.parser=jakarta +# uses javax.servlet.context.tempdir by default +struts.multipart.saveDir= +struts.multipart.maxSize=2097152 + +### Load custom property files (does not override struts.properties!) +# struts.custom.properties=application,org/apache/struts2/extension/custom + +### How request URLs are mapped to and from actions +#struts.mapper.class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper + +### Used by the DefaultActionMapper +### You may provide a comma separated list, e.g. struts.action.extension=action,jnlp,do +### The blank extension allows you to match directory listings as well as pure action names +### without interfering with static resources, which can be specified as an empty string +### prior to a comma e.g. struts.action.extension=, or struts.action.extension=x,y,z,, +struts.action.extension=action,, + +### Used by FilterDispatcher +### If true then Struts serves static content from inside its jar. +### If false then the static content must be available at <context_path>/struts +struts.serve.static=true + +### Used by FilterDispatcher +### This is good for development where one wants changes to the static content be +### fetch on each request. +### NOTE: This will only have effect if struts.serve.static=true +### If true -> Struts will write out header for static contents such that they will +### be cached by web browsers (using Date, Cache-Content, Pragma, Expires) +### headers). +### If false -> Struts will write out header for static contents such that they are +### NOT to be cached by web browser (using Cache-Content, Pragma, Expires +### headers) +struts.serve.static.browserCache=true + +### Set this to false if you wish to disable implicit dynamic method invocation +### via the URL request. This includes URLs like foo!bar.action, as well as params +### like method:bar (but not action:foo). +### An alternative to implicit dynamic method invocation is to use wildcard +### mappings, such as <action name="*/*" method="{2}" class="actions.{1}"> +struts.enable.DynamicMethodInvocation = false + +### Set this to true if you wish to allow slashes in your action names. If false, +### Actions names cannot have slashes, and will be accessible via any directory +### prefix. This is the traditional behavior expected of WebWork applications. +### Setting to true is useful when you want to use wildcards and store values +### in the URL, to be extracted by wildcard patterns, such as +### <action name="*/*" method="{2}" class="actions.{1}"> to match "/foo/edit" or +### "/foo/save". +struts.enable.SlashesInActionNames = false + +### Disables support for action: prefix +struts.mapper.action.prefix.enabled = false + +### Blocks access to actions in other namespace than current with action: prefix +struts.mapper.action.prefix.crossNamespaces = false + +### use alternative syntax that requires %{} in most places +### to evaluate expressions for String attributes for tags +struts.tag.altSyntax=true + +### when set to true, Struts will act much more friendly for developers. This +### includes: +### - struts.i18n.reload = true +### - struts.configuration.xml.reload = true +### - raising various debug or ignorable problems to errors +### For example: normally a request to foo.action?someUnknownField=true should +### be ignored (given that any value can come from the web and it +### should not be trusted). However, during development, it may be +### useful to know when these errors are happening and be told of +### them right away. +struts.devMode = false + +### when set to true, resource bundles will be reloaded on _every_ request. +### this is good during development, but should never be used in production +### struts.i18n.reload=false + +### Standard UI theme +### Change this to reflect which path should be used for JSP control tag templates by default +struts.ui.theme=xhtml +struts.ui.templateDir=template +### Change this to use a different token to indicate template theme expansion +struts.ui.theme.expansion.token=~~~ +#sets the default template type. Either ftl, vm, or jsp +struts.ui.templateSuffix=ftl + +### Configuration reloading +### This will cause the configuration to reload struts.xml when it is changed +### struts.configuration.xml.reload=false + +### Location of velocity.properties file. defaults to velocity.properties +struts.velocity.configfile = velocity.properties + +### Comma separated list of VelocityContext classnames to chain to the StrutsVelocityContext +struts.velocity.contexts = + +### Location of the velocity toolbox +struts.velocity.toolboxlocation= + +### used to build URLs, such as the UrlTag +struts.url.http.port = 80 +struts.url.https.port = 443 +### possible values are: none, get or all +struts.url.includeParams = none + +### Load custom default resource bundles +# struts.custom.i18n.resources=testmessages,testmessages2 + +### workaround for some app servers that don't handle HttpServletRequest.getParameterMap() +### often used for WebLogic, Orion, and OC4J +struts.dispatcher.parametersWorkaround = false + +### configure the Freemarker Manager class to be used +### Allows user to plug-in customised Freemarker Manager if necessary +### MUST extends off org.apache.struts2.views.freemarker.FreemarkerManager +#struts.freemarker.manager.classname=org.apache.struts2.views.freemarker.FreemarkerManager + +### Enables caching of FreeMarker templates +### Has the same effect as copying the templates under WEB_APP/templates +### struts.freemarker.templatesCache=false + +### Enables caching of models on the BeanWrapper +struts.freemarker.beanwrapperCache=false + +### See the StrutsBeanWrapper javadocs for more information +struts.freemarker.wrapper.altMap=true + +### maxStrongSize for MruCacheStorage for freemarker, when set to 0 SoftCacheStorage which performs better in heavy loaded application +### check WW-3766 for more details +struts.freemarker.mru.max.strong.size=0 + +### configure the XSLTResult class to use stylesheet caching. +### Set to true for developers and false for production. +struts.xslt.nocache=false + +### Whether to always select the namespace to be everything before the last slash or not +struts.mapper.alwaysSelectFullNamespace=false + +### Whether to allow static method access in OGNL expressions or not +struts.ognl.allowStaticMethodAccess=false + +### Whether to throw a RuntimeException when a property is not found +### in an expression, or when the expression evaluation fails +struts.el.throwExceptionOnFailure=false + +### Logs as Warnings properties that are not found (very verbose) +struts.ognl.logMissingProperties=false + +### Caches parsed OGNL expressions, but can lead to memory leaks +### if the application generates a lot of different expressions +struts.ognl.enableExpressionCache=true + +### Indicates if Dispatcher should handle unexpected exceptions by calling sendError() +### or simply rethrow it as a ServletException to allow future processing by other frameworks like Spring Security +struts.handle.exception=true +### END SNIPPET: complete_file</code></pre></figure> </section> http://git-wip-us.apache.org/repos/asf/struts-site/blob/f694fc8f/content/core-developers/dispatcher-listener.html ---------------------------------------------------------------------- diff --git a/content/core-developers/dispatcher-listener.html b/content/core-developers/dispatcher-listener.html index 6590955..8da9ed5 100644 --- a/content/core-developers/dispatcher-listener.html +++ b/content/core-developers/dispatcher-listener.html @@ -127,24 +127,24 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/dispatcher-listener.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="dispatcherlistener">DispatcherListener</h1> -<p>Use a DispatcherListener object to execute code when a Dispatcher is initalized or destroyed. A DispatcherListener is an easy way to associate customizable components like a <a href="configuration-provider-and-configuration.html">ConfigurationManager</a> with a Dispatcher.</p> - -<p>####Example####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code> - static { - Dispatcher.addDispatcherListener(new DispatcherListener() { - public void dispatcherInitialized(Dispatcher du) { - // do something to Dispatcher after it is initialized eg. - du.setConfigurationManager(....); - } - - public void dispatcherDestroyed(Dispatcher du) { - // do some cleanup after Dispatcher is destroyed. - } - }); - } - +<p>Use a <code class="highlighter-rouge">DispatcherListener</code> object to execute code when a Dispatcher is initialized or destroyed. A <code class="highlighter-rouge">DispatcherListener</code> +is an easy way to associate customizable components like a <a href="configuration-provider-and-configuration.html">ConfigurationManager</a> +with a Dispatcher.</p> + +<h2 id="example">Example</h2> + +<div class="highlighter-rouge"><pre class="highlight"><code> <span class="kd">static</span> <span class="o">{</span> + <span class="n">Dispatcher</span><span class="o">.</span><span class="na">addDispatcherListener</span><span class="o">(</span><span class="k">new</span> <span class="n">DispatcherListener</span><span class="o">()</span> <span class="o">{</span> + <span class="kd">public</span> <span class="kt">void</span> <span class="n">dispatcherInitialized</span><span class="o">(</span><span class="n">Dispatcher</span> <span class="n">du</span><span class="o">)</span> <span class="o">{</span> + <span class="c1">// do something to Dispatcher after it is initialized eg.</span> + <span class="n">du</span><span class="o">.</span><span class="na">setConfigurationManager</span><span class="o">(....);</span> + <span class="o">}</span> + + <span class="kd">public</span> <span class="kt">void</span> <span class="n">dispatcherDestroyed</span><span class="o">(</span><span class="n">Dispatcher</span> <span class="n">du</span><span class="o">)</span> <span class="o">{</span> + <span class="c1">// do some cleanup after Dispatcher is destroyed.</span> + <span class="o">}</span> + <span class="o">});</span> + <span class="o">}</span> </code></pre> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/f694fc8f/content/core-developers/formatting-dates-and-numbers.html ---------------------------------------------------------------------- diff --git a/content/core-developers/formatting-dates-and-numbers.html b/content/core-developers/formatting-dates-and-numbers.html index 644f94a..15e3cd0 100644 --- a/content/core-developers/formatting-dates-and-numbers.html +++ b/content/core-developers/formatting-dates-and-numbers.html @@ -127,109 +127,87 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/formatting-dates-and-numbers.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="formatting-dates-and-numbers">Formatting Dates and Numbers</h1> -<p>####Defining Formats####</p> +<h2 id="defining-formats">Defining Formats</h2> -<p>Struts2 supports localization (l10n) aware formatting of dates, times and numbers very easily, utilizing Javaâs built-in date formatting features.</p> +<p>Struts2 supports localization (l10n) aware formatting of dates, times and numbers very easily, utilizing Javaâs +built-in date formatting features.</p> -<p>As seen in the <a href="#PAGE_14043">Localization</a> chapter, it is quite easy to define hierarchical resource bundles with Struts2, giving the developer the opportunity to define locale dependent message formats. This is the entry point to define the needed date, time and number formats. Your default properties could contain the following generic formats:</p> +<p>As seen in the <a href="localization.html">Localization</a> chapter, it is quite easy to define hierarchical resource bundles +with Struts2, giving the developer the opportunity to define locale dependent message formats. This is the entry point +to define the needed date, time and number formats. Your default properties could contain the following generic formats:</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -format.time = {0,time} +<div class="highlighter-rouge"><pre class="highlight"><code>format.time = {0,time} format.number = {0,number,#0.0##} format.percent = {0,number,##0.00'%'} format.money = {0,number,\u00A4##0.00} - </code></pre> </div> <p>An appropriate en_US format definition extension could look like this:</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -format.date = {0,date,MM/dd/yy} - +<div class="highlighter-rouge"><pre class="highlight"><code>format.date = {0,date,MM/dd/yy} </code></pre> </div> <p>In parallel, you could add the following to your de_DE bundle:</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -format.date = {0,date,dd.MM.yyyy} - +<div class="highlighter-rouge"><pre class="highlight"><code>format.date = {0,date,dd.MM.yyyy} </code></pre> </div> -<p>Read more on how to define message formats in Sunâs Java API docs for <a href="http://java\.sun\.com/j2se/1\.5\.0/docs/api/java/text/MessageFormat\.html">MessageFormat</a>^[http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html].</p> +<p>Read more on how to define message formats in Sunâs Java API docs for <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html">MessageFormat</a>.</p> <p>Now that we have our formats set up, it is quite easy to use them in our views.</p> -<p>####Formatting output using the s:text tag####</p> +<h2 id="formatting-output-using-the-stext-tag">Formatting output using the s:text tag</h2> -<p>Given you had a Float value myMoneyValue, accessible through the getter getMyMoneyValue in your action, the following code would print out localized representation of the value as a currency amount, using the format.money message format defined above with a <em>s:text</em> tag:</p> +<p>Given you had a Float value myMoneyValue, accessible through the getter getMyMoneyValue in your action, the following +code would print out localized representation of the value as a currency amount, using the format.money message +format defined above with a <code class="highlighter-rouge">s:text</code> tag:</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -<s:text name="format.money"> +<pre><code class="language-jsp"><s:text name="format.money"> <s:param name="value" value="myMoneyValue"/> </s:text> - </code></pre> -</div> <p>The (first) parameter defines the value which is to replace the â0â placeholder in the defined message format.</p> <p>Another example, formatting a date value:</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -<s:text name="format.date"><s:param value="dueDate"/></s:text> - +<pre><code class="language-jsp"><s:text name="format.date"><s:param value="dueDate"/></s:text> </code></pre> -</div> -<table> - <tbody> - <tr> - <td>While the s:text tag is very useful to format numbers, date formatting has become a lot easier thanks to the <em>s:date</em> tag.</td> - </tr> - </tbody> -</table> +<blockquote> + <p>While the <code class="highlighter-rouge">s:text</code> tag is very useful to format numbers, date formatting has become a lot easier thanks +to the <code class="highlighter-rouge">s:date</code> tag.</p> +</blockquote> -<table> - <tbody> - <tr> - </tr> - </tbody> -</table> - -<p>####Localizing form data with getText####</p> +<h2 id="localizing-form-data-with-gettext">Localizing form data with getText</h2> <p>Placing a textfield in a form like this</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -<s:textfield key="orderItem.price" /> - +<pre><code class="language-jsp"><s:textfield key="orderItem.price" /> </code></pre> -</div> - -<p>to input a number, one might have noticed that the number is always shown in the Java default number format. Not only that this is not âniceâ, if you are in a non-en locale, it will also cause trouble when submitting the form since type conversion is locale aware. The solution is to again use the message formats as defined above, by using the getText Method of ActionSupport:</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -<s:textfield key="orderItem.price" value="%{getText('format.number',{orderItem.price})}" /> +<p>to input a number, one might have noticed that the number is always shown in the Java default number format. Not only +that this is not âniceâ, if you are in a non-en locale, it will also cause trouble when submitting the form since type +conversion is locale aware. The solution is to again use the message formats as defined above, by using the getText +method of ActionSupport:</p> +<pre><code class="language-jsp"><s:textfield key="orderItem.price" value="%{getText('format.number',{orderItem.price})}" /> </code></pre> -</div> -<p>This maps to the method signature getText( String key, Object[] params ) in ActionSupport.</p> +<p>This maps to the method signature <code class="highlighter-rouge">getText( String key, Object[] params )</code> in ActionSupport.</p> -<p>####Using getFormatted() with conversion support####</p> +<h2 id="using-getformatted-with-conversion-support">Using getFormatted() with conversion support</h2> -<p>A new method getFormatted was added to ActionSupport (which can be implemented in your base action) to support formatting and conversion errors with I10N.</p> +<p>A new method getFormatted was added to ActionSupport (which can be implemented in your base action) to support +formatting and conversion errors with I10N.</p> <p>You can place a code like below</p> -<div class="highlighter-rouge"><pre class="highlight"><code> -<s:textfield key="user.born" value="%{getFormatted('format.number','user.born')}" /> - +<pre><code class="language-jsp"><s:textfield key="user.born" value="%{getFormatted('format.number','user.born')}" /> </code></pre> -</div> <p>to get support for I10N and also to support conversion errors.</p> http://git-wip-us.apache.org/repos/asf/struts-site/blob/f694fc8f/content/core-developers/index.html ---------------------------------------------------------------------- diff --git a/content/core-developers/index.html b/content/core-developers/index.html index 20ab91c..d6c0f5b 100644 --- a/content/core-developers/index.html +++ b/content/core-developers/index.html @@ -208,9 +208,9 @@ Each may be configured via XML or annotations.</p> <li><a href="accessing-application-session-request-objects.html">Accessing application, session, request objects</a></li> <li><a href="action-mapper-and-action-mapping.html">Action Mapper & Action Mapping</a></li> <li><a href="action-proxy-and-actionproxy-factory.html">Action Proxy & ActionProxy Factory</a></li> - <li>[FAQs] + <li><a href="../faq/">FAQs</a> <ul> - <li><a href="#PAGE_108820">Struts 2 Maven Archetypes</a>\</li> + <li><a href="../maven-archetypes/">Struts 2 Maven Archetypes</a></li> <li>[Cookbook]</li> </ul> </li>