http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/tiles-plugin.html ---------------------------------------------------------------------- diff --git a/content/docs/tiles-plugin.html b/content/docs/tiles-plugin.html index 063c268..58795bf 100644 --- a/content/docs/tiles-plugin.html +++ b/content/docs/tiles-plugin.html @@ -34,20 +34,6 @@ under the License. color: #666; } </style> - <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> - <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> - <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> - <script type="text/javascript"> - SyntaxHighlighter.defaults['toolbar'] = false; - SyntaxHighlighter.all(); - </script> <script type="text/javascript" language="javascript"> var hide = null; var show = null; @@ -139,46 +125,26 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/ -div.rbtoc1499928440617 {padding: 0px;} -div.rbtoc1499928440617 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1499928440617 li {margin-left: 0px;padding-left: 0px;} - -/*]]>*/</style></p><div class="toc-macro rbtoc1499928440617"> -<ul class="toc-indentation"><li><a shape="rect" href="#TilesPlugin-Features">Features</a></li><li><a shape="rect" href="#TilesPlugin-Usage">Usage</a> -<ul class="toc-indentation"><li><a shape="rect" href="#TilesPlugin-AccessingStrutsattributes">Accessing Struts attributes</a></li><li><a shape="rect" href="#TilesPlugin-I18N">I18N</a></li></ul> -</li><li><a shape="rect" href="#TilesPlugin-Example">Example</a></li><li><a shape="rect" href="#TilesPlugin-Settings">Settings</a></li><li><a shape="rect" href="#TilesPlugin-Installation">Installation</a></li></ul> -</div><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Tiles is a templating framework designed to easily allow the creation of web application pages with a consistent look and feel. It can be used for both page decorating and componentization.</p></div></div><p>The Tiles pluginallows actions to return Tiles pages</p><h2 id="TilesPlugin-Features">Features</h2><ul><li>Supports Tiles in Freemarker, JSP, and Velocity</li><li>Provides annotations to keep tiles.xml short and put definitons into actions</li></ul><h2 id="TilesPlugin-Usage">Usage</h2><p>The following steps must be taken in order to enable tiles support within your Struts2 application:</p><ol><li><p>Include the struts-tiles-plugin as a dependency in your web application. If you are using maven2, the dependency configuration will be similar to:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><dependency> + <div id="ConfluenceContent"><rich-text-body><p>Tiles is a templating framework designed to easily allow the creation of web application pages with a consistent look and feel. It can be used for both page decorating and componentization.</p></rich-text-body><p>The Tiles plugin<parameter ac:name="atlassian-macro-output-type">INLINE</parameter><rich-text-body><p>allows actions to return Tiles pages</p></rich-text-body></p><h2 id="TilesPlugin-Features">Features</h2><ul><li>Supports Tiles in Freemarker, JSP, and Velocity</li><li>Provides annotations to keep tiles.xml short and put definitons into actions</li></ul><h2 id="TilesPlugin-Usage">Usage</h2><p>The following steps must be taken in order to enable tiles support within your Struts2 application:</p><ol><li><p>Include the struts-tiles-plugin as a dependency in your web application. If you are using maven2, the dependency configuration will be similar to:</p><parameter ac:name="">xml</parameter><plain-text-body><depende ncy> <groupId>org.apache.struts</groupId> <artifactId>struts2-tiles-plugin</artifactId> <version>${version.tiles}</version> </dependency> -</pre> -</div></div></li><li><p>Register the tiles listener. This listener will typically either be the standard tiles listener (org.apache.tiles.listener.TilesListener) or the Struts2 replacement (org.apache.struts2.tiles.TilesListener). The latter provides tighter integration with Struts features such as freemarker integration.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><listener> +</plain-text-body></li><li><p>Register the tiles listener. This listener will typically either be the standard tiles listener (org.apache.tiles.listener.TilesListener) or the Struts2 replacement (org.apache.struts2.tiles.TilesListener). The latter provides tighter integration with Struts features such as freemarker integration.</p><parameter ac:name="">xml</parameter><plain-text-body><listener> <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class> </listener> -</pre> -</div></div></li><li><p>All package definitions which require tiles support must either extend the tiles-default package or must register the <a shape="rect" class="createlink" href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&title=Tiles+Result&linkCreation=true&fromPageId=27401">Tiles Result</a> type definition.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><result-types> +</plain-text-body></li><li><p>All package definitions which require tiles support must either extend the tiles-default package or must register the <a shape="rect" class="createlink" href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=WW&title=Tiles+Result&linkCreation=true&fromPageId=27401">Tiles Result</a> type definition.</p><parameter ac:name="">xml</parameter><plain-text-body><result-types> <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/> </result-types> -</pre> -</div></div></li><li><p>Configure your actions to utilize a tiles definition:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><action name="sample" class="org.apache.struts2.tiles.example.SampleAction" > +</plain-text-body></li><li><p>Configure your actions to utilize a tiles definition:</p><parameter ac:name="">xml</parameter><plain-text-body><action name="sample" class="org.apache.struts2.tiles.example.SampleAction" > <result name="success" type="tiles">tilesWorks</result> </action> -</pre> -</div></div></li><li><p>Instead of xml configuration you can use annotations</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@Result(name = "success", type="tiles") +</plain-text-body></li><li><p>Instead of xml configuration you can use annotations</p><parameter ac:name="language">java</parameter><plain-text-body>@Result(name = "success", type="tiles") @TilesDefinition(extend = "fooLayout", putAttributes = { @TilesPutAttribute(name = "header", value = "/WEB-INF/tiles/header.jsp"), @TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl") }) -public class FooAction extends ActionSupport {</pre> -</div></div></li><li><p>You have to define Tiles Definitons in a tiles.xml file. That can be placed in <code>resources</code> or in <code>WEB-INF</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><!DOCTYPE tiles-definitions PUBLIC +public class FooAction extends ActionSupport {</plain-text-body></li><li><p>You have to define Tiles Definitons in a tiles.xml file. That can be placed in <code>resources</code> or in <code>WEB-INF</code>.</p><parameter ac:name="language">xml</parameter><plain-text-body><!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" "http://tiles.apache.org/dtds/tiles-config_3_0.dtd"> @@ -195,34 +161,13 @@ public class FooAction extends ActionSupport {</pre> <put-attribute name="body" value="/WEB-INF/tiles/body.jsp"/> </definition> -</tiles-definitions></pre> -</div></div></li></ol><p> </p><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>As from Struts 2.3.28, the plugin automatically loads all Tiles definitions matching the following pattern <code>tiles*.xml</code> - you don't have to specify them via <code>org.apache.tiles.definition.DefinitionsFactory.DEFINITIONS_CONFIG</code> in <code>web.xml</code>, but you can use this option if your application is going to work in restricted servlet environment e.g. Google AppEngine. In such case, definitions will be read from provided <code>init-param</code>.</p></div></div><h3 id="TilesPlugin-AccessingStrutsattributes">Accessing Struts attributes</h3><p>As from Struts version 2.5.3 it's possible accessing defined values on a <code>ValueStack</code> using <code>S2</code> prefix when defining an expression in tiles definition, e.g.:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><definition name="home" extends="logged-in"> +</tiles-definitions></plain-text-body></li></ol><p> </p><rich-text-body><p>As from Struts 2.3.28, the plugin automatically loads all Tiles definitions matching the following pattern <code>tiles*.xml</code> - you don't have to specify them via <code>org.apache.tiles.definition.DefinitionsFactory.DEFINITIONS_CONFIG</code> in <code>web.xml</code>, but you can use this option if your application is going to work in restricted servlet environment e.g. Google AppEngine. In such case, definitions will be read from provided <code>init-param</code>.</p></rich-text-body><h3 id="TilesPlugin-AccessingStrutsattributes">Accessing Struts attributes</h3><p>As from Struts version 2.5.3 it's possible accessing defined values on a <code>ValueStack</code> using <code>S2</code> prefix when defining an expression in tiles definition, e.g.:</p><parameter ac:name="">xml</parameter><plain-text-body><definition name="home" extends="logged-in"> <put-attribute name="title" expression="S2:actionProperty"/> <put-attribute name="body" value="/WEB-INF/tiles/home.jsp"/> -</definition></pre> -</div></div><p>In such case Tiles will delegate evaluation of the expression to Struts and <code>ValueStack</code> will be examined to evaluate the expression.</p><h3 id="TilesPlugin-I18N">I18N</h3><p>Instead of defining new tiles definitions per supported language (i.e.: <code>tiles.xml</code>, <code>tiles_de.xml</code>, <code>tiles_pl.xml</code>) you can use <code>I18N</code> prefix to evaluate provided expression as a key in Struts resource bundles. </p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><definition name="home" extends="logged-in"> +</definition></plain-text-body><p>In such case Tiles will delegate evaluation of the expression to Struts and <code>ValueStack</code> will be examined to evaluate the expression.</p><h3 id="TilesPlugin-I18N">I18N</h3><p>Instead of defining new tiles definitions per supported language (i.e.: <code>tiles.xml</code>, <code>tiles_de.xml</code>, <code>tiles_pl.xml</code>) you can use <code>I18N</code> prefix to evaluate provided expression as a key in Struts resource bundles. </p><parameter ac:name="">xml</parameter><plain-text-body><definition name="home" extends="logged-in"> <put-attribute name="title" expression="I18N:home.title"/> <put-attribute name="body" value="/WEB-INF/tiles/home.jsp"/> -</definition></pre> -</div></div><h2 id="TilesPlugin-Example">Example</h2><p>This example shows a Tiles layout page using Struts tags:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %> -<%@ taglib prefix="s" uri="/struts-tags" %> - -<%-- Show usage; Used in Header --%> -<tiles:importAttribute name="title" scope="request"/> -<html> - <head><title>Struts2 Showcase - <tiles:getAsString name="title"/></title></head> -<body> - <tiles:insertAttribute name="header"/> - <tiles:insertAttribute name="body"/> - <p>Notice that this is a layout made in JSP</p> -</body> -</html> -]]></script> -</div></div>Please check <a shape="rect" class="external-link" href="https://github.com/apache/struts-examples/tree/master/tiles" rel="nofollow">tiles</a> example in <a shape="rect" class="external-link" href="https://github.com/apache/struts-examples/tree/master/tiles" rel="nofollow">struts-examples</a> project.<h2 id="TilesPlugin-Settings">Settings</h2><p>This plugin does inherits settings from <a shape="rect" class="external-link" href="http://tiles.apache.org/config-reference.html">Tiles configuration</a>.</p><h2 id="TilesPlugin-Installation">Installation</h2><p>This plugin can be installed by copying the plugin jar into your application's <code>/WEB-INF/lib</code> directory. No other files need to be copied or created.</p></div> +</definition></plain-text-body><h2 id="TilesPlugin-Example">Example</h2><p>This example shows a Tiles layout page using Struts tags:<plain-text-body>{snippet:url=struts2/apps/showcase/src/main/webapp/WEB-INF/tiles/layout.jsp|lang=xml}</plain-text-body>Please check <a shape="rect" class="external-link" href="https://github.com/apache/struts-examples/tree/master/tiles" rel="nofollow">tiles</a> example in <a shape="rect" class="external-link" href="https://github.com/apache/struts-examples/tree/master/tiles" rel="nofollow">struts-examples</a> project.</p><h2 id="TilesPlugin-Settings">Settings</h2><p>This plugin does inherits settings from <a shape="rect" class="external-link" href="http://tiles.apache.org/config-reference.html">Tiles configuration</a>.</p><h2 id="TilesPlugin-Installation">Installation</h2><p>This plugin can be installed by copying the plugin jar into your application's <code>/WEB-INF/lib</code> directory. No other files need to be copied or created .</p></div> </div> <div class="tabletitle">
http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/timer-interceptor.html ---------------------------------------------------------------------- diff --git a/content/docs/timer-interceptor.html b/content/docs/timer-interceptor.html index 7cbc7f5..fa8e08b 100644 --- a/content/docs/timer-interceptor.html +++ b/content/docs/timer-interceptor.html @@ -161,7 +161,7 @@ Default is to use <code>com.opensymphony.xwork2.interceptor.TimerInterceptor</co <h2 id="TimerInterceptor-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <!-- records only the action's execution time --> <action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="completeStack"/> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/token-interceptor.html ---------------------------------------------------------------------- diff --git a/content/docs/token-interceptor.html b/content/docs/token-interceptor.html index c9afb38..16e343c 100644 --- a/content/docs/token-interceptor.html +++ b/content/docs/token-interceptor.html @@ -185,7 +185,7 @@ interesting logic, such as done with the token session interceptor. <h2 id="TokenInterceptor-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="token"/> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/token-session-interceptor.html ---------------------------------------------------------------------- diff --git a/content/docs/token-session-interceptor.html b/content/docs/token-session-interceptor.html index 9d3c7d2..71bd39b 100644 --- a/content/docs/token-session-interceptor.html +++ b/content/docs/token-session-interceptor.html @@ -170,7 +170,7 @@ There are no known extension points for this interceptor. <h2 id="TokenSessionInterceptor-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="tokenSession/> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/token.html ---------------------------------------------------------------------- diff --git a/content/docs/token.html b/content/docs/token.html index b805ed7..b6edbed 100644 --- a/content/docs/token.html +++ b/content/docs/token.html @@ -157,7 +157,7 @@ the unique token.</p> <h2 id="token-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <s:token /> ]]></script> </div></div></div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/type-conversion.html ---------------------------------------------------------------------- diff --git a/content/docs/type-conversion.html b/content/docs/type-conversion.html index 3b7618e..406127a 100644 --- a/content/docs/type-conversion.html +++ b/content/docs/type-conversion.html @@ -34,20 +34,6 @@ under the License. color: #666; } </style> - <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> - <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> - <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> - <script type="text/javascript"> - SyntaxHighlighter.defaults['toolbar'] = false; - SyntaxHighlighter.all(); - </script> <script type="text/javascript" language="javascript"> var hide = null; var show = null; @@ -141,36 +127,11 @@ under the License. <div class="wiki-content"> <div id="ConfluenceContent"><p>Routine type conversion in the framework is transparent. Generally, all you need to do is ensure that HTML inputs have names that can be used in <a shape="rect" href="ognl.html">OGNL</a> expressions. (HTML inputs are form elements and other GET/POST parameters.)</p> -<style type="text/css">/*<![CDATA[*/ -div.rbtoc1499928285503 {padding: 0px;} -div.rbtoc1499928285503 ul {list-style: none;margin-left: 0px;} -div.rbtoc1499928285503 li {margin-left: 0px;padding-left: 0px;} - -/*]]>*/</style><div class="toc-macro rbtoc1499928285503"> -<ul class="toc-indentation"><li><span class="TOCOutline">1</span> <a shape="rect" href="#TypeConversion-BuiltinTypeConversionSupport">Built in Type Conversion Support</a></li><li><span class="TOCOutline">2</span> <a shape="rect" href="#TypeConversion-RelationshiptoParameterNames">Relationship to Parameter Names</a></li><li><span class="TOCOutline">3</span> <a shape="rect" href="#TypeConversion-CreatingaTypeConverter">Creating a Type Converter</a></li><li><span class="TOCOutline">4</span> <a shape="rect" href="#TypeConversion-ApplyingaTypeConvertertoanAction">Applying a Type Converter to an Action</a></li><li><span class="TOCOutline">5</span> <a shape="rect" href="#TypeConversion-ApplyingaTypeConvertertoabeanormodel">Applying a Type Converter to a bean or model</a></li><li><span class="TOCOutline">6</span> <a shape="rect" href="#TypeConversion-ApplyingaTypeConverterforanapplication">Applying a Type Converter for an application</a></li><li><span class="TOCOutline">7</span> <a shape="r ect" href="#TypeConversion-ASimpleExample">A Simple Example</a></li><li><span class="TOCOutline">8</span> <a shape="rect" href="#TypeConversion-AdvancedTypeConversion">Advanced Type Conversion</a> -<ul class="toc-indentation"><li><span class="TOCOutline">8.1</span> <a shape="rect" href="#TypeConversion-NullPropertyHandling">Null Property Handling</a></li><li><span class="TOCOutline">8.2</span> <a shape="rect" href="#TypeConversion-CollectionandMapSupport">Collection and Map Support</a> -<ul class="toc-indentation"><li><span class="TOCOutline">8.2.1</span> <a shape="rect" href="#TypeConversion-Indexingacollectionbyapropertyofthatcollection">Indexing a collection by a property of that collection</a></li></ul> -</li></ul> -</li><li><span class="TOCOutline">9</span> <a shape="rect" href="#TypeConversion-AnadvancedexampleforindexedListsandMaps">An advanced example for indexed Lists and Maps</a></li><li><span class="TOCOutline">10</span> <a shape="rect" href="#TypeConversion-TypeConversionErrorHandling">Type Conversion Error Handling</a></li><li><span class="TOCOutline">11</span> <a shape="rect" href="#TypeConversion-CommonProblems">Common Problems</a> -<ul class="toc-indentation"><li><span class="TOCOutline">11.1</span> <a shape="rect" href="#TypeConversion-NullandBlankValues">Null and Blank Values</a></li><li><span class="TOCOutline">11.2</span> <a shape="rect" href="#TypeConversion-Interfaces">Interfaces</a></li><li><span class="TOCOutline">11.3</span> <a shape="rect" href="#TypeConversion-GenericsandErasure">Generics and Erasure</a></li></ul> -</li><li><span class="TOCOutline">12</span> <a shape="rect" href="#TypeConversion-Next:">Next: Interceptors</a></li></ul> -</div> +<parameter ac:name="minLevel">2</parameter><parameter ac:name="outline">true</parameter><parameter ac:name="style">none</parameter> <h2 id="TypeConversion-BuiltinTypeConversionSupport">Built in Type Conversion Support</h2> <p>Type Conversion is implemented by XWork.</p> -<p></p><p> -XWork will automatically handle the most common type conversion for you. This includes support for converting to -and from Strings for each of the following: -</p> - -<p></p><ul><li>String</li><li>boolean / Boolean</li><li>char / Character</li><li>int / Integer, float / Float, long / Long, double / Double</li><li>dates - uses the SHORT format for the Locale associated with the current request</li><li>arrays - assuming the individual strings can be coverted to the individual items</li><li>collections - if not object type can be determined, it is assumed to be a String and a new ArrayList is -created</li></ul> - -<p></p><p> Note that with arrays the type conversion will defer to the type of the array elements and try to convert each -item individually. As with any other type conversion, if the conversion can't be performed the standard type -conversion error reporting is used to indicate a problem occurred while processing the type conversion. -</p> - +<plain-text-body>{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter}</plain-text-body> <ul><li>Enumerations</li><li>BigDecimal and BigInteger</li></ul> @@ -186,8 +147,7 @@ conversion error reporting is used to indicate a problem occurred while processi <p>Create a type converter by extending StrutsTypeConverter. The Converter's role is to convert a String to an Object and an Object to a String.</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<plain-text-body> public class MyConverter extends StrutsTypeConverter { public Object convertFromString(Map context, String[] values, Class toClass) { ..... @@ -197,10 +157,9 @@ conversion error reporting is used to indicate a problem occurred while processi ..... } } -</pre> -</div></div> +</plain-text-body> -<div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>To allow Struts to recognize that a conversion error has occurred, the converter class needs to throw XWorkException or preferably TypeConversionException.</p></div></div> +<rich-text-body><p>To allow Struts to recognize that a conversion error has occurred, the converter class needs to throw XWorkException or preferably TypeConversionException.</p></rich-text-body> <h2 id="TypeConversion-ApplyingaTypeConvertertoanAction">Applying a Type Converter to an Action</h2> @@ -209,13 +168,11 @@ conversion error reporting is used to indicate a problem occurred while processi <p>Eg. if the action class name is MyAction, the action-level conversion properties file should be named 'MyAction-conversion.properties'. If the action's package is com.myapp.actions the conversion file should also be in the classpath at /com/myapp/actions/.</p> <p>Within the conversion file, name the action's property and the Converter to apply to it:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<plain-text-body> # syntax: <propertyName> = <converterClassName> point = com.acme.PointConverter person.phoneNumber = com.acme.PhoneNumberConverter -</pre> -</div></div> +</plain-text-body> <p>Type conversion can also be specified via <a shape="rect" href="annotations.html">Annotations</a> within the action.</p> @@ -226,91 +183,29 @@ person.phoneNumber = com.acme.PhoneNumberConverter <p><strong>Example:</strong> A custom converter is required for the Amount property of a Measurement bean. The Measurement class cannot be modified as its located within one of the application's dependencies. The action using Measurement implements ModelDriven<Measurement> so it cannot apply converters to the properties directly.<br clear="none"> <strong>Solution:</strong> The conversion file needs to be in the same location of the classpath as Measurement. Create a directory in your source or resources tree matching the package of Measurement and place the converters file there.<br clear="none"> eg. for com.acme.measurements.Measurement, create a file in the application source/resources at /com/acme/measurements/Measurement-conversion.properties:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: plain; gutter: false; theme: Default" style="font-size:12px;"> +<parameter ac:name="">none</parameter><plain-text-body> # syntax: <propertyName>=<converterClassName> amount=com.acme.converters.MyCustomBigDecimalConverter -</pre> -</div></div> +</plain-text-body> <h2 id="TypeConversion-ApplyingaTypeConverterforanapplication">Applying a Type Converter for an application</h2> <p>Application-wide converters can be specified in a file called xwork-conversion.properties located in the root of the classpath.</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<plain-text-body> # syntax: <type> = <converterClassName> java.math.BigDecimal = com.acme.MyBigDecimalConverter -</pre> -</div></div> +</plain-text-body> <h2 id="TypeConversion-ASimpleExample">A Simple Example</h2> - -<p></p><p> -Type conversion is great for situations where you need to turn a String in to a more complex object. Because the web -is type-agnostic (everything is a string in HTTP), Struts 2's type conversion features are very useful. For instance, -if you were prompting a user to enter in coordinates in the form of a string (such as "3, 22"), you could have -Struts 2 do the conversion both from String to Point and from Point to String. -</p> - -<p></p><p> -Using this "point" example, if your action (or another compound object in which you are setting properties on) -has a corresponding ClassName-conversion.properties file, Struts 2 will use the configured type converters for -conversion to and from strings. So turning "3, 22" in to new Point(3, 22) is done by merely adding the following -entry to <b>ClassName-conversion.properties</b> (Note that the PointConverter should impl the TypeConverter -interface): -</p> -<p><b>point = com.acme.PointConverter</b></p> - -<p></p><p> -Your type converter should be sure to check what class type it is being requested to convert. Because it is used -for both to and from strings, you will need to split the conversion method in to two parts: one that turns Strings in -to Points, and one that turns Points in to Strings. -</p> - -<p></p><p> -After this is done, you can now reference your point (using <s:property value="point"/> in JSP or ${point} -in FreeMarker) and it will be printed as "3, 22" again. As such, if you submit this back to an action, it will be -converted back to a Point once again. -</p> - -<p></p><p> -In some situations you may wish to apply a type converter globally. This can be done by editing the file -<b>xwork-conversion.properties</b> in the root of your class path (typically WEB-INF/classes) and providing a -property in the form of the class name of the object you wish to convert on the left hand side and the class name of -the type converter on the right hand side. For example, providing a type converter for all Point objects would mean -adding the following entry: -</p> - -<p></p><p><b>com.acme.Point = com.acme.PointConverter</b></p> - -<div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"> -<p></p><p> -Type conversion should not be used as a substitute for i18n. It is not recommended to use this feature to print out -properly formatted dates. Rather, you should use the i18n features of Struts 2 (and consult the JavaDocs for JDK's -MessageFormat object) to see how a properly formatted date should be displayed. -</p></div></div> +<plain-text-body>{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.conversion.impl.XWorkConverter}</plain-text-body> +<rich-text-body> +<plain-text-body>{snippet:id=i18n-note|javadoc=true|url=com.opensymphony.xwork2.conversion.impl.XWorkConverter}</plain-text-body></rich-text-body> <p>The framework ships with a base helper class that simplifies converting to and from Strings, <code>org.apache.struts2.util.StrutsTypeConverter</code>. The helper class makes it easy to write type converters that handle converting objects to Strings as well as from Strings.</p> <p>From the JavaDocs:</p> - -<p></p><p> -Base class for type converters used in Struts. This class provides two abstract methods that are used to convert -both to and from strings – the critical functionality that is core to Struts's type conversion system. -</p> -<p> Type converters do not have to use this class. It is merely a helper base class, although it is recommended that -you use this class as it provides the common type conversion contract required for all web-based type conversion. -</p> - -<p></p><p> There's a hook (fall back method) called <code>performFallbackConversion</code> of which -could be used to perform some fallback conversion if <code>convertValue</code> method of this -failed. By default it just ask its super class (Ognl's DefaultTypeConverter) to do the conversion. -</p> - -<p></p><p> To allow the framework to recognize that a conversion error has occurred, throw an XWorkException or -preferable a TypeConversionException. -</p> +<plain-text-body>{snippet:id=javadoc|javadoc=true|url=org.apache.struts2.util.StrutsTypeConverter}</plain-text-body> <h2 id="TypeConversion-AdvancedTypeConversion">Advanced Type Conversion</h2> @@ -319,43 +214,15 @@ preferable a TypeConversionException. <h3 id="TypeConversion-NullPropertyHandling">Null Property Handling</h3> <p>Null property handling will automatically create objects where null references are found.</p> -<p></p><p> -Provided that the key ReflectionContextState#CREATE_NULL_OBJECTS is in the action context with a value of true (this key is set -only during the execution of the com.opensymphony.xwork2.interceptor.ParametersInterceptor), OGNL expressions -that have caused a NullPointerException will be temporarily stopped for evaluation while the system automatically -tries to solve the null references by automatically creating the object. -</p> - -<p></p><p>The following rules are used when handling null references:</p> - -<p></p><ul><li>If the property is declared <i>exactly</i> as a Collection or List, then an ArrayList shall be -returned and assigned to the null references.</li><li>If the property is declared as a Map, then a HashMap will be returned and assigned to the null -references.</li><li>If the null property is a simple bean with a no-arg constructor, it will simply be created using the {@link -ObjectFactory#buildBean(java.lang.Class, java.util.Map)} method.</li></ul> - -<p></p><p> -For example, if a form element has a text field named <b>person.name</b> and the expression <i>person</i> evaluates -to null, then this class will be invoked. Because the <i>person</i> expression evaluates to a <i>Person</i> class, a -new Person is created and assigned to the null reference. Finally, the name is set on that object and the overall -effect is that the system automatically created a Person object for you, set it by calling setUsers() and then -finally called getUsers().setName() as you would typically expect. -</p> +<plain-text-body>{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler}</plain-text-body> +<plain-text-body>{snippet:id=example|javadoc=true|url=com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler}</plain-text-body> <h3 id="TypeConversion-CollectionandMapSupport">Collection and Map Support</h3> <p>Collection and Map support provides intelligent null handling and type conversion for Java Collections.</p> <p>The framework supports ways to discover the object type for elements in a collection. The discover is made via an <em>ObjectTypeDeterminer</em>. A default implementation is provided with the framework. The Javadocs explain how Map and Collection support is discovered in the <code>DefaultObjectTypeDeterminer</code>.</p> - -<p>This ObjectTypeDeterminer looks at the <b>Class-conversion.properties</b> for entries that indicated what -objects are contained within Maps and Collections. For Collections, such as Lists, the element is specified using the -pattern <b>Element_xxx</b>, where xxx is the field name of the collection property in your action or object. For -Maps, both the key and the value may be specified by using the pattern <b>Key_xxx</b> and <b>Element_xxx</b>, -respectively.</p> - -<p></p><p> From WebWork 2.1.x, the <b>Collection_xxx</b> format is still supported and honored, although it is deprecated -and will be removed eventually.</p> - +<plain-text-body>{snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer}</plain-text-body> <p>Additionally, you can create your own custom <code>ObjectTypeDeterminer</code> by implementing the <code>ObjectTypeDeterminer</code> interface. There is also an optional ObjectTypeDeterminer that utilizes Java 5 generics. See the <a shape="rect" href="annotations.html">Annotations</a> page for more information.</p> <h4 id="TypeConversion-Indexingacollectionbyapropertyofthatcollection">Indexing a collection by a property of that collection</h4> @@ -363,8 +230,7 @@ and will be removed eventually.</p> <p>It is also possible to obtain a unique element of a collection by passing the value of a given property of that element. By default, the property of the element of the collection is determined in <em>Class</em>-conversion.properties using <code>KeyProperty_xxx=yyy</code>, where xxx is the property of the bean <em>Class</em> that returns the collection and yyy is the property of the collection element that we want to index on.</p> <p>For an example, see the following two classes:</p> -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>MyAction.java</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<parameter ac:name="title">MyAction.java</parameter><parameter ac:name="borderStyle">solid</parameter><plain-text-body> /** * @return a Collection of Foo objects */ @@ -372,10 +238,8 @@ public Collection getFooCollection() { return foo; } -</pre> -</div></div> -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>Foo.java</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +</plain-text-body> +<parameter ac:name="title">Foo.java</parameter><parameter ac:name="borderStyle">solid</parameter><plain-text-body> /** * @return a unique identifier */ @@ -383,8 +247,7 @@ public Long getId() { return id; } -</pre> -</div></div> +</plain-text-body> <p>To enable type conversion, put the instruction <code>KeyProperty_fooCollection=id</code> in the <code>MyAction-conversion.properties</code> file. This technique allows use of the idiom <code>fooCollection(someIdValue)</code> to obtain the Foo object with value <code>someIdValue</code> in the Set <code>fooCollection</code>. For example, <code>fooCollection(22)</code> would return the Foo object in the <code>fooCollection</code> Collection whose <code>id</code> property value was 22.</p> <p>This technique is useful, because it ties a collection element directly to its unique identifier. You are not forced to use an index. You can edit the elements of a collection associated to a bean without any additional coding. For example, parameter name <code>fooCollection(22).name</code> and value <code>Phil</code> would set name the Foo Object in the <code>fooCollection</code> Collection whose <code>id</code> property value was 22 to be Phil.</p> @@ -396,8 +259,7 @@ public Long getId() <h2 id="TypeConversion-AnadvancedexampleforindexedListsandMaps">An advanced example for indexed Lists and Maps</h2> <p>Here is the model bean used within the list. The KeyProperty for this bean is the <code>id</code> attribute.</p> -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>MyBean.java</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<parameter ac:name="title">MyBean.java</parameter><parameter ac:name="borderStyle">solid</parameter><plain-text-body> public class MyBean implements Serializable { private Long id; @@ -427,11 +289,9 @@ public class MyBean implements Serializable { '}'; } } -</pre> -</div></div> +</plain-text-body> <p>The Action has a <code>beanList</code> attribute initialized with an empty ArrayList.</p> -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>MyBeanAction.java</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<parameter ac:name="title">MyBeanAction.java</parameter><parameter ac:name="borderStyle">solid</parameter><plain-text-body> public class MyBeanAction implements Action { private List beanList = new ArrayList(); @@ -457,16 +317,13 @@ public class MyBeanAction implements Action { return SUCCESS; } } -</pre> -</div></div> +</plain-text-body> <p>These <code>conversion.properties</code> tell the TypeConverter to use MyBean instances as elements of the List.</p> -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>MyBeanAction-conversion.properties</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<parameter ac:name="title">MyBeanAction-conversion.properties</parameter><parameter ac:name="borderStyle">solid</parameter><plain-text-body> KeyProperty_beanList=id Element_beanList=MyBean CreateIfNull_beanList=true -</pre> -</div></div> +</plain-text-body> <ul><li>When submitting this via a form, the <code>id</code> value is used as KeyProperty for the MyBean instances in the beanList.</li></ul> @@ -479,37 +336,16 @@ CreateIfNull_beanList=true <ul><li>The List does not have null values added for unavailable id values. This approach avoids the risk of OutOfMemoryErrors!</li></ul> -<div class="code panel pdl" style="border-style: solid;border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;border-bottom-style: solid;"><b>MyBeanAction.jsp</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<parameter ac:name="title">MyBeanAction.jsp</parameter><parameter ac:name="borderStyle">solid</parameter><plain-text-body> <s:iterator value="beanList" id="bean"> <stextfield name="beanList(%{bean.id}).name" /> </s:iterator> -</pre> -</div></div> +</plain-text-body> <h2 id="TypeConversion-TypeConversionErrorHandling">Type Conversion Error Handling</h2> <p>Type conversion error handling provides a simple way to distinguish between an input <em>validation</em> problem and an input <em>type conversion</em> problem.</p> -<p></p><p> -Any error that occurs during type conversion may or may not wish to be reported. For example, reporting that the -input "abc" could not be converted to a number might be important. On the other hand, reporting that an empty string, -"", cannot be converted to a number might not be important - especially in a web environment where it is hard to -distinguish between a user not entering a value vs. entering a blank value. -</p> -<p> By default, all conversion errors are reported using the generic i18n key <b>xwork.default.invalid.fieldvalue</b>, -which you can override (the default text is <i>Invalid field value for field "xxx"</i>, where xxx is the field name) -in your global i18n resource bundle. -</p> - -<p></p><p>However, sometimes you may wish to override this message on a per-field basis. You can do this by adding an i18n -key associated with just your action (Action.properties) using the pattern <b>invalid.fieldvalue.xxx</b>, where xxx -is the field name. -</p> - -<p></p><p>It is important to know that none of these errors are actually reported directly. Rather, they are added to a map -called <i>conversionErrors</i> in the ActionContext. There are several ways this map can then be accessed and the -errors can be reported accordingly. -</p> +<plain-text-body>{snippet:id=error-reporting|javadoc=true|url=com.opensymphony.xwork2.conversion.impl.XWorkConverter}</plain-text-body> <p>There are two ways the error reporting can occur:</p> <ol><li>Globally, using the <a shape="rect" href="conversion-error-interceptor.html">Conversion Error Interceptor</a></li><li>On a per-field basis, using the <a shape="rect" href="conversion-validator.html">conversion validator</a></li></ol> @@ -530,8 +366,7 @@ errors can be reported accordingly. <p>The following is an example of this problem:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<plain-text-body> public abstract class Measurement<T extends Enum> public void setUnits(T enumValue) {...} } @@ -540,8 +375,7 @@ public class Area extends Measurement<UnitsOfArea> { @Override public void setUnits(UnitsOfArea enumValue){...} } -</pre> -</div></div> +</plain-text-body> <p>Although to the developer the area.setUnits(enumValue) method only accepts a UnitsOfArea enumeration, due to erasure the signature of this method is actually setUnits(java.lang.Enum). The framework does not know that the parameter is a UnitsOfArea and when it attempts to instantiate the Enum an exception is thrown (java.lang.IllegalArgumentException: java.lang.Enum is not an enum type).</p> <h2 id="TypeConversion-Next:">Next: <a shape="rect" href="interceptors.html">Interceptors</a></h2></div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/typeconversion-annotation.html ---------------------------------------------------------------------- diff --git a/content/docs/typeconversion-annotation.html b/content/docs/typeconversion-annotation.html index 45d9470..1b63daa 100644 --- a/content/docs/typeconversion-annotation.html +++ b/content/docs/typeconversion-annotation.html @@ -166,7 +166,7 @@ Set type to: <code>type = ConversionType.APPLICATION</code> <h2 id="TypeConversionAnnotation-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ @Conversion() public class ConversionAction implements Action { http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/updownselect.html ---------------------------------------------------------------------- diff --git a/content/docs/updownselect.html b/content/docs/updownselect.html index 4e9c431..d3d28f1 100644 --- a/content/docs/updownselect.html +++ b/content/docs/updownselect.html @@ -162,7 +162,7 @@ the order they are arranged (top to bottom). <h2 id="updownselect-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <!-- Example 1: simple example --> <s:updownselect http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/url.html ---------------------------------------------------------------------- diff --git a/content/docs/url.html b/content/docs/url.html index 31d3756..18f9f70 100644 --- a/content/docs/url.html +++ b/content/docs/url.html @@ -172,7 +172,7 @@ because the parameter defined in the param tag will take precedence.</p> <p>The property <em>struts.url.includeParams</em> can be used to set the default value of the <em>includeParams</em> attribute.</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Setting the default value of includeParams</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"> +<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> <struts> ... <constant name="struts.url.includeParams" value="none" /> @@ -192,7 +192,7 @@ because the parameter defined in the param tag will take precedence.</p> <h1 id="url-Examples">Examples</h1> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <-- Example 1 --> <s:url value="editGadget.action"> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/using-field-validators.html ---------------------------------------------------------------------- diff --git a/content/docs/using-field-validators.html b/content/docs/using-field-validators.html index f86a9ac..fc9dcf2 100644 --- a/content/docs/using-field-validators.html +++ b/content/docs/using-field-validators.html @@ -34,20 +34,6 @@ under the License. color: #666; } </style> - <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> - <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> - <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> - <script type="text/javascript"> - SyntaxHighlighter.defaults['toolbar'] = false; - SyntaxHighlighter.all(); - </script> <script type="text/javascript" language="javascript"> var hide = null; var show = null; @@ -139,196 +125,7 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><h2 id="UsingFieldValidators-Description">Description</h2><p>The followings show a simple example using Struts' Field Validators</p><h3 id="UsingFieldValidators-Step1">Step 1</h3><p>Create the jsp page</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ - -<h3>All Field Errors Will Appear Here</h3> -<s:fielderror/> -<hr/> - -<h3>Field Error due to 'Required String Validator Field' Will Appear Here</h3> -<s:fielderror> - <s:param value="%{'requiredStringValidatorField'}"/> -</s:fielderror> -<hr/> - -<h3>Field Error due to 'String Length Validator Field' Will Appear Here</h3> -<s:fielderror> - <s:param>stringLengthValidatorField</s:param> -</s:fielderror> -<hr/> - -<s:form action="submitFieldValidatorsExamples" namespace="/validation" method="POST" theme="xhtml"> - <s:textfield label="Required Validator Field" name="requiredValidatorField"/> - <s:textfield label="Required String Validator Field" name="requiredStringValidatorField"/> - <s:textfield label="Integer Validator Field" name="integerValidatorField"/> - <s:textfield label="Date Validator Field" name="dateValidatorField"/> - <s:textfield label="Email Validator Field" name="emailValidatorField"/> - <s:textfield label="URL Validator Field" name="urlValidatorField"/> - <s:textfield label="String Length Validator Field" name="stringLengthValidatorField"/> - <s:textfield label="Regex Validator Field" name="regexValidatorField"/> - <s:textfield label="Field Expression Validator Field" name="fieldExpressionValidatorField"/> - <s:submit label="Submit" cssClass="btn btn-primary"/> -</s:form> - -]]></script> -</div></div><h3 id="UsingFieldValidators-Step2">Step 2</h3><p>Create the action class</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ - */ -public class FieldValidatorsExampleAction extends AbstractValidationActionSupport { - - private static final long serialVersionUID = -4829381083003175423L; - - private String requiredValidatorField = null; - private String requiredStringValidatorField = null; - private Integer integerValidatorField = null; - private Date dateValidatorField = null; - private String emailValidatorField = null; - private String urlValidatorField = null; - private String stringLengthValidatorField = null; - private String regexValidatorField = null; - private String fieldExpressionValidatorField = null; - - - public Date getDateValidatorField() { - return dateValidatorField; - } - - public void setDateValidatorField(Date dateValidatorField) { - this.dateValidatorField = dateValidatorField; - } - - public String getEmailValidatorField() { - return emailValidatorField; - } - - public void setEmailValidatorField(String emailValidatorField) { - this.emailValidatorField = emailValidatorField; - } - - public Integer getIntegerValidatorField() { - return integerValidatorField; - } - - public void setIntegerValidatorField(Integer integerValidatorField) { - this.integerValidatorField = integerValidatorField; - } - - public String getRegexValidatorField() { - return regexValidatorField; - } - - public void setRegexValidatorField(String regexValidatorField) { - this.regexValidatorField = regexValidatorField; - } - - public String getRequiredStringValidatorField() { - return requiredStringValidatorField; - } - - public void setRequiredStringValidatorField(String requiredStringValidatorField) { - this.requiredStringValidatorField = requiredStringValidatorField; - } - - public String getRequiredValidatorField() { - return requiredValidatorField; - } - - public void setRequiredValidatorField(String requiredValidatorField) { - this.requiredValidatorField = requiredValidatorField; - } - - public String getStringLengthValidatorField() { - return stringLengthValidatorField; - } - - public void setStringLengthValidatorField(String stringLengthValidatorField) { - this.stringLengthValidatorField = stringLengthValidatorField; - } - - public String getFieldExpressionValidatorField() { - return fieldExpressionValidatorField; - } - - public void setFieldExpressionValidatorField( - String fieldExpressionValidatorField) { - this.fieldExpressionValidatorField = fieldExpressionValidatorField; - } - - public String getUrlValidatorField() { - return urlValidatorField; - } - - public void setUrlValidatorField(String urlValidatorField) { - this.urlValidatorField = urlValidatorField; - } -} - -/** -]]></script> -</div></div><h3 id="UsingFieldValidators-Step3">Step 3</h3><p>Create the validator.xml.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ - -<validators> - <field name="requiredValidatorField"> - <field-validator type="required"> - <message><![CDATA[ required ]]></message> - </field-validator> - </field> - <field name="requiredStringValidatorField"> - <field-validator type="requiredstring"> - <param name="trim">true</param> - <message><![CDATA[ required and must be string ]]></message> - </field-validator> - </field> - <field name="integerValidatorField"> - <field-validator type="int"> - <param name="min">1</param> - <param name="max">10</param> - <message><![CDATA[ must be integer min 1 max 10 if supplied ]]></message> - </field-validator> - </field> - <field name="dateValidatorField"> - <field-validator type="date"> - <param name="min">01/01/1990</param> - <param name="max">01/01/2000</param> - <message><![CDATA[ must be a min 01-01-1990 max 01-01-2000 if supplied ]]></message> - </field-validator> - </field> - <field name="emailValidatorField"> - <field-validator type="email"> - <message><![CDATA[ must be a valid email if supplied ]]></message> - </field-validator> - </field> - <field name="urlValidatorField"> - <field-validator type="url"> - <message><![CDATA[ must be a valid url if supplied ]]></message> - </field-validator> - </field> - <field name="stringLengthValidatorField"> - <field-validator type="stringlength"> - <param name="maxLength">4</param> - <param name="minLength">2</param> - <param name="trim">true</param> - <message><![CDATA[ must be a String of a specific greater than 1 less than 5 if specified ]]></message> - </field-validator> - </field> - <field name="regexValidatorField"> - <field-validator type="regex"> - <param name="regex"><![CDATA[ [^<>]+ ]]></param> - <message><![CDATA[ regexValidatorField must match a regexp (.*\.txt) if specified ]]></message> - </field-validator> - </field> - <field name="fieldExpressionValidatorField"> - <field-validator type="fieldexpression"> - <param name="expression">(fieldExpressionValidatorField == requiredValidatorField)</param> - <message><![CDATA[ must be the same as the Required Validator Field if specified ]]></message> - </field-validator> - </field> -</validators> - -]]></script> -</div></div></div> + <div id="ConfluenceContent"><h2 id="UsingFieldValidators-Description">Description</h2><p>The followings show a simple example using Struts' Field Validators</p><h3 id="UsingFieldValidators-Step1">Step 1</h3><p>Create the jsp page<plain-text-body>{snippet:id=fieldValidatorsExample|lang=xml|javadoc=false|url=struts2/apps/showcase/src/main/webapp/WEB-INF/validation/fieldValidatorsExample.jsp}</plain-text-body></p><h3 id="UsingFieldValidators-Step2">Step 2</h3><p>Create the action class<plain-text-body>{snippet:id=fieldValidatorsExample|javadoc=false|lang=java|url=struts2/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/FieldValidatorsExampleAction.java}</plain-text-body></p><h3 id="UsingFieldValidators-Step3">Step 3</h3><p>Create the validator.xml.<plain-text-body>{snippet:id=fieldValidatorsExample|javadoc=false|lang=xml|url=struts2/apps/showcase/src/main/resources/org/apache/struts2/showcase/validation/FieldValidatorsExampleAction-submitFieldValidatorsExa mples-validation.xml}</plain-text-body></p></div> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/using-non-field-validators.html ---------------------------------------------------------------------- diff --git a/content/docs/using-non-field-validators.html b/content/docs/using-non-field-validators.html index 00e33b3..a5976e7 100644 --- a/content/docs/using-non-field-validators.html +++ b/content/docs/using-non-field-validators.html @@ -34,20 +34,6 @@ under the License. color: #666; } </style> - <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> - <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> - <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> - <script type="text/javascript"> - SyntaxHighlighter.defaults['toolbar'] = false; - SyntaxHighlighter.all(); - </script> <script type="text/javascript" language="javascript"> var hide = null; var show = null; @@ -139,69 +125,7 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><h2 id="UsingNonFieldValidators-Description">Description</h2><p>The followings show a simple example using Webwork's Non Field Validators</p><h3 id="UsingNonFieldValidators-Step1">Step 1</h3><p>Create the jsp page</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ -<s:actionerror/> - -<s:form method="POST" action="submitNonFieldValidatorsExamples" namespace="/validation"> - <s:textfield name="someText" label="Some Text"/> - <s:textfield name="someTextRetype" label="Retype Some Text"/> - <s:textfield name="someTextRetypeAgain" label="Retype Some Text Again"/> - <s:submit label="Submit" cssClass="btn btn-primary"/> -</s:form> - - -]]></script> -</div></div><h3 id="UsingNonFieldValidators-Step2">Step 2</h3><p>Create the action class</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ - -public class NonFieldValidatorsExampleAction extends AbstractValidationActionSupport { - - private static final long serialVersionUID = -524460368233581186L; - - private String someText; - private String someTextRetype; - private String someTextRetypeAgain; - - public String getSomeText() { - return someText; - } - - public void setSomeText(String someText) { - this.someText = someText; - } - - public String getSomeTextRetype() { - return someTextRetype; - } - - public void setSomeTextRetype(String someTextRetype) { - this.someTextRetype = someTextRetype; - } - - public String getSomeTextRetypeAgain() { - return someTextRetypeAgain; - } - - public void setSomeTextRetypeAgain(String someTextRetypeAgain) { - this.someTextRetypeAgain = someTextRetypeAgain; - } -} - - -]]></script> -</div></div><h3 id="UsingNonFieldValidators-Step3">Step 3</h3><p>Create the validator.xml.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ - -<validators> - <validator type="expression"> - <param name="expression"><![CDATA[ ( (someText == someTextRetype) && (someTextRetype == someTextRetypeAgain) ) ]]></param> - <message><![CDATA[ all three text must be exactly the same ]]></message> - </validator> -</validators> - -]]></script> -</div></div></div> + <div id="ConfluenceContent"><h2 id="UsingNonFieldValidators-Description">Description</h2><p>The followings show a simple example using Webwork's Non Field Validators</p><h3 id="UsingNonFieldValidators-Step1">Step 1</h3><p>Create the jsp page<plain-text-body>{snippet:id=nonFieldValidatorsExample|lang=xml|javadoc=false|url=struts2/apps/showcase/src/main/webapp/WEB-INF/validation/nonFieldValidatorsExample.jsp}</plain-text-body></p><h3 id="UsingNonFieldValidators-Step2">Step 2</h3><p>Create the action class<plain-text-body>{snippet:id=nonFieldValidatorsExample|javadoc=false|lang=java|url=struts2/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/NonFieldValidatorsExampleAction.java}</plain-text-body></p><h3 id="UsingNonFieldValidators-Step3">Step 3</h3><p>Create the validator.xml.<plain-text-body>{snippet:id=nonFieldValidatorsExample|javadoc=false|lang=xml|url=struts2/apps/showcase/src/main/resources/org/apache/struts2/showcase/validation/NonFieldValidatorsEx ampleAction-submitNonFieldValidatorsExamples-validation.xml}</plain-text-body></p></div> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/using-visitor-field-validator.html ---------------------------------------------------------------------- diff --git a/content/docs/using-visitor-field-validator.html b/content/docs/using-visitor-field-validator.html index 6788ef0..2e8dc40 100644 --- a/content/docs/using-visitor-field-validator.html +++ b/content/docs/using-visitor-field-validator.html @@ -34,20 +34,6 @@ under the License. color: #666; } </style> - <link href='https://struts.apache.org/highlighter/style/shCoreStruts.css' rel='stylesheet' type='text/css' /> - <link href='https://struts.apache.org/highlighter/style/shThemeStruts.css' rel='stylesheet' type='text/css' /> - <script src='https://struts.apache.org/highlighter/js/shCore.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushPlain.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushXml.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJava.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushJScript.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushGroovy.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushBash.js' type='text/javascript'></script> - <script src='https://struts.apache.org/highlighter/js/shBrushCss.js' type='text/javascript'></script> - <script type="text/javascript"> - SyntaxHighlighter.defaults['toolbar'] = false; - SyntaxHighlighter.all(); - </script> <script type="text/javascript" language="javascript"> var hide = null; var show = null; @@ -139,55 +125,7 @@ under the License. <div class="pagecontent"> <div class="wiki-content"> - <div id="ConfluenceContent"><h2 id="UsingVisitorFieldValidator-Description">Description</h2><p>The followings show a simple example using Webwork's Field Validators</p><h3 id="UsingVisitorFieldValidator-Step1">Step 1</h3><p>Create the jsp page.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ - -<s:fielderror cssClass="alert alert-error"/> - -<s:form method="POST" action="submitVisitorValidatorsExamples" namespace="/validation"> - <s:textfield name="user.name" label="User Name"/> - <s:textfield name="user.age" label="User Age"/> - <s:textfield name="user.birthday" label="Birthday"/> - <s:submit label="Submit" cssClass="btn btn-primary"/> -</s:form> - -]]></script> -</div></div><h3 id="UsingVisitorFieldValidator-Step2">Step 2</h3><p>Create the action class.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ - -public class VisitorValidatorsExampleAction extends AbstractValidationActionSupport { - - private static final long serialVersionUID = 4375454086939598216L; - - private User user; - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } -} - - -]]></script> -</div></div><h3 id="UsingVisitorFieldValidator-Step3">Step 3</h3><p>Create the validator.xml.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ - -<validators> - <field name="user"> - <field-validator type="visitor"> - <param name="context">userContext</param> - <param name="appendPrefix">true</param> - <message>User:</message> - </field-validator> - </field> -</validators> - - -]]></script> -</div></div></div> + <div id="ConfluenceContent"><h2 id="UsingVisitorFieldValidator-Description">Description</h2><p>The followings show a simple example using Webwork's Field Validators</p><h3 id="UsingVisitorFieldValidator-Step1">Step 1</h3><p>Create the jsp page.<plain-text-body>{snippet:id=visitorValidatorsExample|lang=xml|javadoc=false|url=struts2/apps/showcase/src/main/webapp/WEB-INF/validation/visitorValidatorsExample.jsp}</plain-text-body></p><h3 id="UsingVisitorFieldValidator-Step2">Step 2</h3><p>Create the action class.<plain-text-body>{snippet:id=visitorValidatorsExample|javadoc=false|lang=java|url=struts2/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/VisitorValidatorsExampleAction.java}</plain-text-body></p><h3 id="UsingVisitorFieldValidator-Step3">Step 3</h3><p>Create the validator.xml.<plain-text-body>{snippet:id=visitorValidatorsExample|javadoc=false|lang=xml|url=struts2/apps/showcase/src/main/resources/org/apache/struts2/showcase/validation/VisitorValidato rsExampleAction-submitVisitorValidatorsExamples-validation.xml}</plain-text-body></p></div> </div> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/validation-annotation.html ---------------------------------------------------------------------- diff --git a/content/docs/validation-annotation.html b/content/docs/validation-annotation.html index 9516133..c6b2309 100644 --- a/content/docs/validation-annotation.html +++ b/content/docs/validation-annotation.html @@ -157,7 +157,7 @@ is no longer necessary.</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ @Validation() public interface AnnotationDataAware { @@ -175,7 +175,7 @@ public interface AnnotationDataAware { </div></div> <p><strong>An Annotated Class</strong></p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ @Validation() public class SimpleAnnotationAction extends ActionSupport { @@ -224,7 +224,7 @@ public class SimpleAnnotationAction extends ActionSupport { <p>When multiple methods are used to map different actions on the same class, and one of them is annotated with <em>@Validations</em>, those validators will be triggered for all the actions, unless they are annotated with @SkipValidation or <em>validateAnnotatedMethodOnly</em> is set to <em>true</em> in the "validation" interceptor, like:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> +<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> <interceptor-ref name="validation"> <param name="validateAnnotatedMethodOnly">true</param> <param name="excludeMethods">input,back,cancel,browse</param> http://git-wip-us.apache.org/repos/asf/struts-site/blob/b16cc4ef/content/docs/validation-interceptor.html ---------------------------------------------------------------------- diff --git a/content/docs/validation-interceptor.html b/content/docs/validation-interceptor.html index aa7ff22..55c7bc8 100644 --- a/content/docs/validation-interceptor.html +++ b/content/docs/validation-interceptor.html @@ -185,7 +185,7 @@ and any method that starts with "validate". <h2 id="ValidationInterceptor-Examples">Examples</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ +<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[ <action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="params"/>