[struts-site] branch asf-site updated: Updates production by Jenkins

2018-06-05 Thread git-site-role
This is an automated email from the ASF dual-hosted git repository.

git-site-role pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/struts-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
 new 53fc0ef  Updates production by Jenkins
53fc0ef is described below

commit 53fc0ef618ec8314806b05c55a9df9dab6769bda
Author: jenkins 
AuthorDate: Tue Jun 5 09:16:05 2018 +

Updates production by Jenkins
---
 content/core-developers/validation.html | 74 -
 1 file changed, 73 insertions(+), 1 deletion(-)

diff --git a/content/core-developers/validation.html 
b/content/core-developers/validation.html
index 4250408..107deb3 100644
--- a/content/core-developers/validation.html
+++ b/content/core-developers/validation.html
@@ -141,7 +141,14 @@
   Validator 
Scopes
   Notes
   Defining Validation Rules
-  Localizing and 
Parameterizing Messages
+  Localizing and 
Parameterizing Messages
+  Customizing validation 
messages
+  XML
+  Annotations
+
+  
+
+  
   Validator 
Flavor
   Non-Field
 Validator Vs Field-Validator validatortypes
   Short-Circuiting Validator
@@ -425,6 +432,71 @@ it is possible to construct quite sophisticated 
messages.
 
 
 
+Customizing validation messages
+
+There is another option to customise validation messages by using 
parametrized messages. Either you can use them via
+XML or with annotations.
+
+XML
+
+To use this new approach you must use a proper header in a ActionName-validation.xml file, see 
below:
+
+?xml version="1.0"?
+!DOCTYPE validators PUBLIC
+"-//Apache Struts//XWork Validator 1.0.3//EN"
+"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd";
+validators
+  ...
+/validators
+
+
+
+Now you can define validators that will use parametrized messages as 
below:
+
+field name="username"
+field-validator type="requiredstring"
+message key="errors.required"
+param name="0"getText('username.field.name')/param
+/message
+/field-validator
+/field
+
+
+
+
+  NOTE: Please be aware that all the parameters will be evaluated against 
ValueStack, please do not reference user
+controlled values or incoming parameters in request as this can lead to a 
security vulnerability
+
+
+Now you can define your properties file with localized messages:
+
+errors.required={0} is required.
+username.field.name=Username
+
+
+
+As you can see you defined a errors.required key with a placeholder for the 
param. The names of the params are not important,
+order is important as this mechanism uses MessageFormat to format the message.
+
+The final output will be as follow:
+
+Username is 
required.
+
+
+
+Annotations
+
+The same mechanism can be used with annotations as follow:
+
+@RequiredStringValidator(key = "errors.required", messageParams = {
+"getText('username.field.name')"
+})
+public void setUsername(String username) 
{
+this.username = username;
+}
+
+
+
 Validator Flavor
 
 The validators supplied by the XWork distribution (and any validators you 
might write yourself) come in two different 

-- 
To stop receiving notification emails like this one, please contact
git-site-r...@apache.org.


[struts-site] branch master updated: WW-4940 Adds missing section about customising validation messages

2018-06-05 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts-site.git


The following commit(s) were added to refs/heads/master by this push:
 new cf6c8f5  WW-4940 Adds missing section about customising validation 
messages
cf6c8f5 is described below

commit cf6c8f50937c2b1411d19a3f14107c817497fbf8
Author: Lukasz Lenart 
AuthorDate: Tue Jun 5 11:05:46 2018 +0200

WW-4940 Adds missing section about customising validation messages
---
 source/core-developers/validation.md | 63 
 1 file changed, 63 insertions(+)

diff --git a/source/core-developers/validation.md 
b/source/core-developers/validation.md
index 2842fc4..d39ff0e 100644
--- a/source/core-developers/validation.md
+++ b/source/core-developers/validation.md
@@ -234,6 +234,69 @@ See the following example to get an impression:
 ${getText("validation.failednotice")} ! ${getText("reason")}: 
${getText("validation.inputrequired")}
 ```
 
+### Customizing validation messages
+
+There is another option to customise validation messages by using parametrized 
messages. Either you can use them via
+XML or with annotations.
+
+ XML
+
+To use this new approach you must use a proper header in a 
`-validation.xml` file, see below:
+
+```xml
+
+http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd;>
+
+  ...
+
+```
+
+Now you can define validators that will use parametrized messages as below:
+
+```xml
+
+
+
+getText('username.field.name')
+
+
+
+```
+
+> NOTE: Please be aware that all the parameters will be evaluated against 
`ValueStack`, please do not reference user
+> controlled values or incoming parameters in request as this can lead to a 
security vulnerability
+
+Now you can define your properties file with localized messages:
+
+```
+errors.required={0} is required.
+username.field.name=Username
+```
+
+As you can see you defined a `errors.required` key with a placeholder for the 
param. The names of the params are not important,
+order is important as this mechanism uses `MessageFormat` to format the 
message.
+
+The final output will be as follow:
+
+```
+Username is required.
+```
+
+ Annotations
+
+The same mechanism can be used with annotations as follow:
+
+```java
+@RequiredStringValidator(key = "errors.required", messageParams = {
+"getText('username.field.name')"
+})
+public void setUsername(String username) {
+this.username = username;
+}
+```
+
 ## Validator Flavor
 
 The validators supplied by the XWork distribution (and any validators you 
might write yourself) come in two different 

-- 
To stop receiving notification emails like this one, please contact
lukaszlen...@apache.org.


[struts-examples] branch master updated: WW-4940 Adds an example app how to customise validation messages

2018-06-05 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts-examples.git


The following commit(s) were added to refs/heads/master by this push:
 new 1c6ff24  WW-4940 Adds an example app how to customise validation 
messages
1c6ff24 is described below

commit 1c6ff24bb6d6e9c1aca4be48c1d59e85e47bea31
Author: Lukasz Lenart 
AuthorDate: Tue Jun 5 10:28:50 2018 +0200

WW-4940 Adds an example app how to customise validation messages
---
 pom.xml|  5 +-
 validation-messages/pom.xml| 39 ++
 .../struts/validation_messages/ExampleSupport.java |  6 +++
 .../apache/struts/validation_messages/Login.java   | 59 ++
 validation-messages/src/main/resources/log4j2.xml  | 16 ++
 .../validation_messages/Login-validation.xml   | 21 
 .../struts/validation_messages/package.properties  |  4 ++
 .../validation_messages/package_es.properties  |  4 ++
 validation-messages/src/main/resources/struts.xml  | 34 +
 .../src/main/webapp/WEB-INF/Login.jsp  | 15 ++
 .../src/main/webapp/WEB-INF/Menu.jsp   |  3 ++
 .../src/main/webapp/WEB-INF/Missing.jsp| 11 
 .../src/main/webapp/WEB-INF/web.xml| 23 +
 validation-messages/src/main/webapp/index.html | 10 
 14 files changed, 248 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index bd9e91c..ce77ea2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -83,10 +83,11 @@
 type-conversion
 unit-testing
 using-tags
+validation-messages
 wildcard-method-selection
 wildcard-regex
 unknown-handler
-
+  
 
 
 
@@ -167,4 +168,4 @@
 
 
 
-
+
\ No newline at end of file
diff --git a/validation-messages/pom.xml b/validation-messages/pom.xml
new file mode 100644
index 000..131dbb7
--- /dev/null
+++ b/validation-messages/pom.xml
@@ -0,0 +1,39 @@
+
+http://maven.apache.org/POM/4.0.0; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd;>
+4.0.0
+
+struts-examples
+org.apache.struts
+1.0.0
+
+
+validation-messages
+validation-messages
+Struts 2 example application how to customise validation 
messages
+
+war
+
+
+validation-messages
+
+
+org.eclipse.jetty
+jetty-maven-plugin
+${jetty-plugin.version}
+
+
+/${project.artifactId}
+
+CTRL+C
+8999
+10
+
+
src/main/webapp/WEB-INF/web.xml
+
+
+
+
+
+
+
diff --git 
a/validation-messages/src/main/java/org/apache/struts/validation_messages/ExampleSupport.java
 
b/validation-messages/src/main/java/org/apache/struts/validation_messages/ExampleSupport.java
new file mode 100644
index 000..ed08c2d
--- /dev/null
+++ 
b/validation-messages/src/main/java/org/apache/struts/validation_messages/ExampleSupport.java
@@ -0,0 +1,6 @@
+package org.apache.struts.validation_messages;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+public class ExampleSupport extends ActionSupport {
+}
diff --git 
a/validation-messages/src/main/java/org/apache/struts/validation_messages/Login.java
 
b/validation-messages/src/main/java/org/apache/struts/validation_messages/Login.java
new file mode 100644
index 000..6fec733
--- /dev/null
+++ 
b/validation-messages/src/main/java/org/apache/struts/validation_messages/Login.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.struts.validation_messages;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+public class Login extends ExampleSupport {
+
+public String execute() {
+
+if (isInvalid(getUsername())) return INPUT;
+
+if