Repository: struts-site Updated Branches: refs/heads/asf-site 5fe99b224 -> 0898ed78f
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/0898ed78 Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/0898ed78 Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/0898ed78 Branch: refs/heads/asf-site Commit: 0898ed78f845d543350dd723e3d1dd3cb59d38bb Parents: 5fe99b2 Author: jenkins <bui...@apache.org> Authored: Sun Sep 10 21:31:32 2017 +0000 Committer: jenkins <bui...@apache.org> Committed: Sun Sep 10 21:31:32 2017 +0000 ---------------------------------------------------------------------- .../core-developers/conversion-validator.html | 92 +++++++++++++++----- content/core-developers/date-validator.html | 68 ++++++++++----- content/core-developers/double-validator.html | 69 ++++++++++----- content/core-developers/required-validator.html | 45 ++++++---- .../requiredstring-validator.html | 55 ++++++++---- 5 files changed, 230 insertions(+), 99 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-site/blob/0898ed78/content/core-developers/conversion-validator.html ---------------------------------------------------------------------- diff --git a/content/core-developers/conversion-validator.html b/content/core-developers/conversion-validator.html index c55533c..80f38db 100644 --- a/content/core-developers/conversion-validator.html +++ b/content/core-developers/conversion-validator.html @@ -127,44 +127,90 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/conversion-validator.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="conversion-validator">conversion validator</h1> -<p>####Description####</p> +<h3 id="description">Description</h3> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> +<p>Field Validator that checks if a conversion error occurred for this field.</p> -<p>####Parameters####</p> +<h3 id="parameters">Parameters</h3> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> +<ul> + <li><code class="highlighter-rouge">fieldName</code> - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required.</li> +</ul> -<p>####Examples####</p> +<h3 id="examples">Examples</h3> -<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.validator.validators.ConversionErrorFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> +<div class="highlighter-rouge"><pre class="highlight"><code><!-- Plain Validator Syntax --> +<validator type="conversion"> + <param name="fieldName">myField</param> + <message>Conversion Error Occurred</message> +</validator> + +<!-- Field Validator Syntax --> +<field name="myField"> + <field-validator type="conversion"> + <message>Conversion Error Occurred</message> + </field-validator> +</field> +</code></pre> </div> -<p>####Repopulating Field upon conversion Error####</p> +<h3 id="repopulating-field-upon-conversion-error">Repopulating Field upon conversion Error</h3> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> +<p>The capability of auto-repopulating the stack with a fake parameter map when a conversion error has occurred can be done with <code class="highlighter-rouge">repopulateField</code> property set to <code class="highlighter-rouge">true</code>.</p> + +<p>This is typically useful when one wants to repopulate the field with the original value when a conversion error occurred. Eg. with a textfield that only allows an Integer (the action class have an Integer field declared), upon conversion error, the incorrectly entered integer (maybe a text âoneâ) will not appear when dispatched back. With <code class="highlighter-rouge">repopulateField</code> property set to true, it will, meaning the textfield will have âoneâ as its value upon conversion error.</p> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=exampleJspPage|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport</span><span class="p">}</span><span class="w"> -</span></code></pre> +<div class="highlighter-rouge"><pre class="highlight"><code><!-- myJspPage.jsp --> +<s:form action="someAction" method="POST"> + .... + <s:textfield label="My Integer Field" name="myIntegerField" /> + .... + <s:submit /> +</s:form> +</code></pre> </div> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=exampleXwork|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport</span><span class="p">}</span><span class="w"> -</span></code></pre> +<div class="highlighter-rouge"><pre class="highlight"><code><!-- xwork.xml --> +<xwork> +<include file="xwork-default.xml" /> +.... +<package name="myPackage" extends="xwork-default"> + .... + <action name="someAction" class="example.MyActionSupport.java"> + <result name="input">myJspPage.jsp</result> + <result>success.jsp</result> + </action> + .... +</package> +.... +</xwork> +</code></pre> </div> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=exampleJava|lang=java|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport</span><span class="p">}</span><span class="w"> -</span></code></pre> +<div class="highlighter-rouge"><pre class="highlight"><code><!-- MyActionSupport.java --> +public class MyActionSupport extends ActionSupport { + private Integer myIntegerField; + + public Integer getMyIntegerField() { return this.myIntegerField; } + public void setMyIntegerField(Integer myIntegerField) { + this.myIntegerField = myIntegerField; + } +} +</code></pre> </div> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=exampleValidation|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RepopulateConversionErrorFieldValidatorSupport</span><span class="p">}</span><span class="w"> -</span></code></pre> +<div class="highlighter-rouge"><pre class="highlight"><code><!-- MyActionSupport-someAction-validation.xml --> +<validators> + ... + <field name="myIntegerField"> + <field-validator type="conversion"> + <param name="repopulateField">true</param> + <message>Conversion Error (Integer Wanted)</message> + </field-validator> + </field> + ... +</validators> +</code></pre> </div> </section> http://git-wip-us.apache.org/repos/asf/struts-site/blob/0898ed78/content/core-developers/date-validator.html ---------------------------------------------------------------------- diff --git a/content/core-developers/date-validator.html b/content/core-developers/date-validator.html index 09c1f02..87fa0c9 100644 --- a/content/core-developers/date-validator.html +++ b/content/core-developers/date-validator.html @@ -127,36 +127,60 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/date-validator.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="date-validator">date validator</h1> -<p>####Description####</p> +<h3 id="description">Description</h3> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> +<p>Field Validator that checks if the date supplied is within a specific range.</p> -<p>####Parameters####</p> +<p><strong>NOTE:</strong> If no date converter is specified, <code class="highlighter-rouge">XWorkBasicConverter</code> will kick in to do the date conversion, which by default using the <code class="highlighter-rouge">Date.SHORT</code> format using the a problematically specified locale else falling back to the system default locale.</p> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> +<h3 id="parameters">Parameters</h3> -<p><strong>(!) Warning</strong></p> +<ul> + <li>`fieldName - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required.</li> + <li><code class="highlighter-rouge">min</code> - the min date range. If not specified will not be checked.</li> + <li><code class="highlighter-rouge">max</code> - the max date range. If not specified will not be checked.</li> + <li><code class="highlighter-rouge">parse</code> - if set to true, minExpression and maxExpression will be evaluated to find min/max.</li> + <li><code class="highlighter-rouge">minExpression</code> - expression to calculate the minimum value (if none is specified, it will not be checked).</li> + <li><code class="highlighter-rouge">maxExpression</code> - expression to calculate the maximum value (if none is specified, it will not be checked).</li> +</ul> + +<p>You can either use the min / max value or minExpression / maxExpression (when parse is set to true) - using expression can be slightly slower, see the example below.</p> <blockquote> - <table> - <tbody> - <tr> - <td>{snippet:id=parameters-warning</td> - <td>javadoc=true</td> - <td>url=com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator}</td> - </tr> - </tbody> - </table> + <p>Warning +Do not use <code class="highlighter-rouge">${minExpression}</code> and <code class="highlighter-rouge">${maxExpression}</code> as an expression as this will turn into infinitive loop!</p> </blockquote> -<p>####Examples####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> +<h3 id="examples">Examples</h3> + +<div class="highlighter-rouge"><pre class="highlight"><code><validators> + <!-- Plain Validator syntax --> + <validator type="date"> + <param name="fieldName">birthday</param> + <param name="min">01/01/1990</param> + <param name="max">01/01/2000</param> + <message>Birthday must be within ${min} and ${max}</message> + </validator> + + <!-- Field Validator Syntax --> + <field name="birthday"> + <field-validator type="date"> + <param name="min">01/01/1990</param> + <param name="max">01/01/2000</param> + <message>Birthday must be within ${min} and ${max}</message> + </field-validator> + </field> + + <!-- Field Validator Syntax with expression --> + <field name="birthday"> + <field-validator type="date"> + <param name="minExpression">${minValue}</param> <!-- will be evaluated as: Date getMinValue() --> + <param name="maxExpression">${maxValue}</param> <!-- will be evaluated as: Date getMaxValue() --> + <message>Age needs to be between ${min} and ${max}</message> + </field-validator> + </field> +</validators> +</code></pre> </div> </section> http://git-wip-us.apache.org/repos/asf/struts-site/blob/0898ed78/content/core-developers/double-validator.html ---------------------------------------------------------------------- diff --git a/content/core-developers/double-validator.html b/content/core-developers/double-validator.html index ca13a2c..a5ac7f2 100644 --- a/content/core-developers/double-validator.html +++ b/content/core-developers/double-validator.html @@ -127,36 +127,61 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/double-validator.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="double-validator">double validator</h1> -<p>####Description####</p> +<h3 id="description">Description</h3> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> +<p>Field Validator that checks if the double specified is within a certain range.</p> -<p>####Parameters####</p> +<h3 id="parameters">Parameters</h3> -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> +<ul> + <li><code class="highlighter-rouge">fieldName</code> - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required.</li> + <li><code class="highlighter-rouge">minInclusive</code> - the minimum inclusive value in FloatValue format specified by Java language (if none is specified, it will not be checked).</li> + <li><code class="highlighter-rouge">maxInclusive</code> - the maximum inclusive value in FloatValue format specified by Java language (if none is specified, it will not be checked).</li> + <li><code class="highlighter-rouge">minExclusive</code> - the minimum exclusive value in FloatValue format specified by Java language (if none is specified, it will not be checked).</li> + <li><code class="highlighter-rouge">maxExclusive</code> - the maximum exclusive value in FloatValue format specified by Java language (if none is specified, it will not be checked).</li> + <li><code class="highlighter-rouge">minInclusiveExpression</code> - the minimum inclusive value specified as a OGNL expression (if none is specified, it will not be checked).</li> + <li><code class="highlighter-rouge">maxInclusiveExpression</code> - the maximum inclusive value specified as a OGNL expression (if none is specified, it will not be checked).</li> + <li><code class="highlighter-rouge">minExclusiveExpression</code> - the minimum exclusive value specified as a OGNL expression (if none is specified, it will not be checked).</li> + <li><code class="highlighter-rouge">maxExclusiveExpression</code> - the maximum exclusive value specified as a OGNL expression (if none is specified, it will not be checked).</li> +</ul> -<p><strong>(!) Warning</strong></p> +<p>You can specify either <code class="highlighter-rouge">minInclusive</code>, <code class="highlighter-rouge">maxInclusive</code>, <code class="highlighter-rouge">minExclusive</code> and <code class="highlighter-rouge">maxExclusive</code> or <code class="highlighter-rouge">minInclusiveExpression</code>, <code class="highlighter-rouge">maxInclusiveExpression</code>, <code class="highlighter-rouge">minExclusiveExpression</code> and <code class="highlighter-rouge">maxExclusiveExpression</code> as a OGNL expression, see example below. You can always try to mix params but be aware that such behaviour was not tested.</p> <blockquote> - <table> - <tbody> - <tr> - <td>{snippet:id=parameters-warning</td> - <td>javadoc=true</td> - <td>url=com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator}</td> - </tr> - </tbody> - </table> + <p>Warning +Do not use <code class="highlighter-rouge">${minInclusiveExpression}</code>, <code class="highlighter-rouge">${maxInclusiveExpression}</code>, <code class="highlighter-rouge">${minExclusiveExpressionExpression}</code> and <code class="highlighter-rouge">${maxExclusive}</code> as an expression as this will turn into infinitive loop!</p> </blockquote> -<p>####Examples####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> +<h3 id="examples">Examples</h3> + +<div class="highlighter-rouge"><pre class="highlight"><code><validators> + <!-- Plain Validator Syntax --> + <validator type="double"> + <param name="fieldName">percentage</param> + <param name="minInclusive">20.1</param> + <param name="maxInclusive">50.1</param> + <message>Age needs to be between ${minInclusive} and ${maxInclusive} (inclusive)</message> + </validator> + + <!-- Field Validator Syntax --> + <field name="percentage"> + <field-validator type="double"> + <param name="minExclusive">0.123</param> + <param name="maxExclusive">99.98</param> + <message>Percentage needs to be between ${minExclusive} and ${maxExclusive} (exclusive)</message> + </field-validator> + </field> + + <!-- Field Validator Syntax with expression --> + <field name="percentage"> + <field-validator type="double"> + <param name="minExclusiveExpression">${minExclusiveValue}</param> <!-- will be evaluated as: Double getMinExclusiveValue() --> + <param name="maxExclusiveExpression">${maxExclusiveValue}</param> <!-- will be evaluated as: Double getMaxExclusiveValue() --> + <message>Percentage needs to be between ${minExclusive} and ${maxExclusive} (exclusive)</message> + </field-validator> + </field> +</validators> +</code></pre> </div> </section> http://git-wip-us.apache.org/repos/asf/struts-site/blob/0898ed78/content/core-developers/required-validator.html ---------------------------------------------------------------------- diff --git a/content/core-developers/required-validator.html b/content/core-developers/required-validator.html index 8bdf190..705ce76 100644 --- a/content/core-developers/required-validator.html +++ b/content/core-developers/required-validator.html @@ -127,22 +127,35 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/required-validator.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="required-validator">required validator</h1> -<p>####Description####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RequiredFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> - -<p>####Parameters####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RequiredFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> - -<p>####Examples####</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.validator.validators.RequiredFieldValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> +<h3 id="description">Description</h3> + +<p>RequiredFieldValidator checks if the specified field is not null.</p> + +<h3 id="parameters">Parameters</h3> + +<ul> + <li><code class="highlighter-rouge">fieldName</code> - field name if plain-validator syntax is used, not needed if field-validator syntax is used.</li> +</ul> + +<h3 id="examples">Examples</h3> + +<div class="highlighter-rouge"><pre class="highlight"><code><validators> + <!-- Plain Validator Syntax --> + <validator type="required"> + <param name="fieldName">username</param> + <message>username must not be null</message> + </validator> + + + <!-- Field Validator Syntax --> + <field name="username"> + <field-validator type="required"> + <message>username must not be null</message> + </field-validator> + </field> + +</validators> +</code></pre> </div> </section> http://git-wip-us.apache.org/repos/asf/struts-site/blob/0898ed78/content/core-developers/requiredstring-validator.html ---------------------------------------------------------------------- diff --git a/content/core-developers/requiredstring-validator.html b/content/core-developers/requiredstring-validator.html index 4d0ba17..a418982 100644 --- a/content/core-developers/requiredstring-validator.html +++ b/content/core-developers/requiredstring-validator.html @@ -127,22 +127,45 @@ <a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/requiredstring-validator.md" title="Edit this page on GitHub">Edit on GitHub</a> <h1 id="requiredstring-validator">requiredstring validator</h1> -<p>####Description####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=javadoc|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RequiredStringValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> - -<p>####Parameters####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=parameters|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RequiredStringValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> -</div> - -<p>####Examples####</p> - -<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="err">snippet:id=examples|lang=xml|javadoc=true|url=com.opensymphony.xwork2.validator.validators.RequiredStringValidator</span><span class="p">}</span><span class="w"> -</span></code></pre> +<h3 id="description">Description</h3> + +<p>RequiredStringValidator checks that a String field is non-null and has a length > 0. (i.e. it isnât ââ). The <code class="highlighter-rouge">trim</code> parameter determines whether it will <code class="highlighter-rouge">String#trim()</code> the String before performing the length check. If unspecified, the String will be trimmed.</p> + +<h3 id="parameters">Parameters</h3> + +<ul> + <li><code class="highlighter-rouge">fieldName</code> - The field name this validator is validating. Required if using Plain-Validator Syntax otherwise not required.</li> + <li><code class="highlighter-rouge">trim</code> - (Optional) Boolean, default true. Trims the field name value before validating.</li> + <li><code class="highlighter-rouge">trimExpression</code> - (Optional) String. Specifies the trim param as an OGNL expression.</li> +</ul> + +<h3 id="examples">Examples</h3> + +<div class="highlighter-rouge"><pre class="highlight"><code><validators> + <!-- Plain-Validator Syntax --> + <validator type="requiredstring"> + <param name="fieldName">username</param> + <param name="trim">true</param> + <message>username is required</message> + </validator> + + <!-- Field-Validator Syntax --> + <field name="username"> + <field-validator type="requiredstring"> + <param name="trim">true</param> + <message>username is required</message> + </field-validator> + </field> + + <!-- Field-Validator Syntax with expression --> + <field name="username"> + <field-validator type="requiredstring"> + <param name="trimExpression">${trimValue}</param> <!-- will be evaluated as: boolean getTrimValue() --> + <message>username is required</message> + </field-validator> + </field> +</validators> +</code></pre> </div> </section>