This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch cleanup in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/cleanup by this push: new 1f0c95453 Improves formatting 1f0c95453 is described below commit 1f0c95453bc32ff0ee9d4e265086a748e0e352b7 Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Thu Apr 7 14:31:37 2022 +0200 Improves formatting --- source/core-developers/using-field-validators.md | 2 - .../core-developers/using-non-field-validators.md | 114 +++++++++------------ 2 files changed, 46 insertions(+), 70 deletions(-) diff --git a/source/core-developers/using-field-validators.md b/source/core-developers/using-field-validators.md index 32c2d1e99..f0a424861 100644 --- a/source/core-developers/using-field-validators.md +++ b/source/core-developers/using-field-validators.md @@ -21,7 +21,6 @@ The followings show a simple example using Struts' Field Validators Create the jsp page ```html - <h3>All Field Errors Will Appear Here</h3> <s:fielderror/> <hr/> @@ -150,7 +149,6 @@ public class FieldValidatorsExampleAction extends AbstractValidationActionSuppor Create the `validator.xml`. ```xml - <validators> <field name="requiredValidatorField"> <field-validator type="required"> diff --git a/source/core-developers/using-non-field-validators.md b/source/core-developers/using-non-field-validators.md index 745e2c7bc..da37d0d43 100644 --- a/source/core-developers/using-non-field-validators.md +++ b/source/core-developers/using-non-field-validators.md @@ -1,99 +1,77 @@ --- -layout: core-developers +layout: default title: Using Non Field Validators +parent: + title: Validation + url: validation.html --- # Using Non Field Validators +{:.no_toc} -## Description - -The followings show a simple example using Webwork's Non Field Validators - -__Step 1__ +* Will be replaced with the ToC, excluding a header +{:toc} -Create the jsp page - -{% comment %}start snippet id=nonFieldValidatorsExample|lang=xml|javadoc=false|url=struts2/apps/showcase/src/main/webapp/WEB-INF/validation/nonFieldValidatorsExample.jsp {% endcomment %} - -```xml - <s:actionerror/> +## Description - <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> +The followings show a simple example using Struts' Non Field Validators +## Create the jsp page +```html +<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> ``` -{% comment %}end snippet id=nonFieldValidatorsExample|lang=xml|javadoc=false|url=struts2/apps/showcase/src/main/webapp/WEB-INF/validation/nonFieldValidatorsExample.jsp {% endcomment %} - -__Step 2__ - -Create the action class - -{% comment %}start snippet id=nonFieldValidatorsExample|javadoc=false|lang=java|url=struts2/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/NonFieldValidatorsExampleAction.java {% endcomment %} +## Create the action class ```java - public class NonFieldValidatorsExampleAction extends AbstractValidationActionSupport { - private static final long serialVersionUID = -524460368233581186L; + private String someText; + private String someTextRetype; + private String someTextRetypeAgain; - private String someText; - private String someTextRetype; - private String someTextRetypeAgain; + public String getSomeText() { + return someText; + } - public String getSomeText() { - return someText; - } + public void setSomeText(String someText) { + this.someText = someText; + } - public void setSomeText(String someText) { - this.someText = someText; - } + public String getSomeTextRetype() { + return someTextRetype; + } - public String getSomeTextRetype() { - return someTextRetype; - } + public void setSomeTextRetype(String someTextRetype) { + this.someTextRetype = someTextRetype; + } - public void setSomeTextRetype(String someTextRetype) { - this.someTextRetype = someTextRetype; - } + public String getSomeTextRetypeAgain() { + return someTextRetypeAgain; + } - public String getSomeTextRetypeAgain() { - return someTextRetypeAgain; - } - - public void setSomeTextRetypeAgain(String someTextRetypeAgain) { - this.someTextRetypeAgain = someTextRetypeAgain; - } + public void setSomeTextRetypeAgain(String someTextRetypeAgain) { + this.someTextRetypeAgain = someTextRetypeAgain; + } } - - - ``` -{% comment %}end snippet id=nonFieldValidatorsExample|javadoc=false|lang=java|url=struts2/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/NonFieldValidatorsExampleAction.java {% endcomment %} - -__Step 3__ - -Create the validator\.xml\. - -{% comment %}start snippet id=nonFieldValidatorsExample|javadoc=false|lang=xml|url=struts2/apps/showcase/src/main/resources/org/apache/struts2/showcase/validation/NonFieldValidatorsExampleAction-submitNonFieldValidatorsExamples-validation.xml {% endcomment %} +## Create the `validator.xml`. ```xml - <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> + <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> - - ``` - -{% comment %}end snippet id=nonFieldValidatorsExample|javadoc=false|lang=xml|url=struts2/apps/showcase/src/main/resources/org/apache/struts2/showcase/validation/NonFieldValidatorsExampleAction-submitNonFieldValidatorsExamples-validation.xml {% endcomment %}