Commits

Anonymous committed 6fd141f

change quiz validation example to support providing arguments to i18n message (XW-591)

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@2974573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 5d9e6fc

Comments (0)

Files changed (3)

File webapps/showcase/src/java/com/opensymphony/webwork/showcase/validation/QuizAction-validation.xml

-<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<!DOCTYPE validators PUBLIC
+        "-//OpenSymphony Group//XWork Validator 1.0.3//EN"
+        "http://www.opensymphony.com/xwork/xwork-validator-1.0.3.dtd">
 
 <!--  START SNIPPET: quizValidators -->
 <!--
 <validators>
     <field name="name">
         <field-validator type="requiredstring">
-            <message key="validation.name.required"/>
+            <message key="validation.name.required" />
         </field-validator>
     </field>
     <field name="age">
         <field-validator type="int">
-            <param name="min">13</param>
+            <param name="min">10</param>
             <param name="max">19</param>
-            <message key="validation.age.invalid" />
+            <message key="validation.age.invalid">
+                <param name="0">'Contestant'</param>
+                <param name="1">minAge</param>
+                <param name="2">maxAge</param>
+                <param name="defaultMessage">Your age, its invalid</param>
+            </message>
         </field-validator>
     </field>
 </validators>

File webapps/showcase/src/java/com/opensymphony/webwork/showcase/validation/QuizAction.java

 // START SNIPPET: quizAction 
 
 public class QuizAction extends ActionSupport {
+    int minAge = 13;
+    int maxAge = 19;
+
     String name;
     int age;
     String answer;
 
+    public int getMinAge() {
+        return minAge;
+    }
+
+    public void setMinAge(int minAge) {
+        this.minAge = minAge;
+    }
+
+    public int getMaxAge() {
+        return maxAge;
+    }
+
+    public void setMaxAge(int maxAge) {
+        this.maxAge = maxAge;
+    }
+
     public String getName() {
         return name;
     }

File webapps/showcase/src/java/com/opensymphony/webwork/showcase/validation/QuizAction.properties

 validation.name.required=You must enter a name
-validation.age.invalid=Only people ages 13 to 19 may take this quiz
+validation.age.invalid=Dear {0}, Only people ages {1} to {2} may take this quiz