Commits

tm_jee  committed 1214eee

WW-1392
- alter ajax (client) validation example to try to simuate this issue where i18n messages generated by ajax-validation could be internationalized

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

  • Participants
  • Parent commits 23c7763

Comments (0)

Files changed (4)

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

 <validators>
     <field name="name">
         <field-validator type="requiredstring">
-            <message>You must enter a name</message>
+            <message key="validation.name.required"/>
         </field-validator>
     </field>
     <field name="age">
         <field-validator type="int">
             <param name="min">13</param>
             <param name="max">19</param>
-            <message>Only people ages 13 to 19 may take this quiz</message>
+            <message key="validation.age.invalid" />
         </field-validator>
     </field>
 </validators>

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

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

+validation.name.required=(cn) You must enter a name
+validation.age.invalid=(cn) Only people ages 13 to 19 may take this quiz

File webapps/showcase/src/webapp/validation/quiz-ajax.jsp

 <%@ taglib prefix="ww" uri="/webwork" %>
+<%@page import="com.opensymphony.xwork.*" %>
+<%@page import="java.util.*" %>
 
 <!-- START SNIPPET: ajaxValidation -->
 
 
 <body>
 
-<div id="r">test</div>
-
-<ww:form id="f1" action="quizAjax" namespace="/validation" method="post" validate="false" theme="ajax">
+This quiz (ajax) example is customized to use 2 locale, namely en_US and cn_ZH, as I don't know 
+how to write / read chinese, the chinese resource bundle is just like the english but prefixed with (cn)
+<ul>
+	<li>
+		<ww:url id="url" namespace="/validation" action="quizAjax" method="input">
+			<ww:param name="request_locale" value="%{'zh_CN'}" />
+		</ww:url>
+		To swich to use the chinese resource bundle click <ww:a href="%{#url}">here</ww:a>.
+	</li>
+	<li>
+		<ww:url id="url" namespace="/validation" action="quizAjax" method="input">
+			<ww:param name="request_locale" value="%{'en_US'}" />
+		</ww:url>
+		To swich to use the english resource bundle click <ww:a href="%{#url}">here</ww:a>.
+	</li>
+</ul>
+
+The following form uses the labelposition="left"
+<ww:form id="f1" action="quizAjax" namespace="/validation" method="post" validate="true" theme="ajax">
     <ww:textfield label="Name" name="name" labelposition="left" />
     <ww:textfield label="Age" name="age" labelposition="left" />
     <ww:textfield label="Favorite color" name="answer" labelposition="left" />
     <ww:submit id="b1" />
 </ww:form>
 
+The following form uses the labelposition="top"
 <ww:form id="f2" action="quizAjax" namespace="/validation" method="post" validate="true" theme="ajax">
     <ww:textfield label="Name" name="name" labelposition="top" />
     <ww:textfield label="Age" name="age" labelposition="top" />