Commits

Anonymous committed 20ea4c0

added javadoc explaining how validation message could be internationalized. A user have doubts
in this area as it is not documented. see http://forums.opensymphony.com/thread.jspa?threadID=109693

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/xwork_1-2/src@1582e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits d75167d

Comments (0)

Files changed (1)

java/com/opensymphony/xwork/validator/Validator.java

  * </p>
  * <!-- END SNIPPET: howXworkFindsValidatorForAction -->
  *
+ *
+ * <p/>
+ * <!-- START SNIPPET: i18n -->
+ * Validator's validation messages could be internatinalized. For example,
+ * <pre>
+ *   &lt;field-validator type="required"&gt;
+ *      &lt;message key="required.field" /&gt;
+ *   &lt;/field-validator&gt;
+ * </pre>
+ * or
+ * <pre>
+ *   &lt;validator type="expression"&gt;
+ *      &lt;param name="expression"&gt;email.startsWith('Mark')&lt;/param&gt;
+ *      &lt;message key="email.invalid" /&gt;
+ *   &lt;/validator&gt;
+ * </pre>
+ * In the first case, WebWork would look for i18n with key 'required.field' as the validation error message if
+ * validation fails, and 'email.invalid' in the second case.
+ * <p/>
+ * We could also provide a default message such that if validation failed and the i18n key for the message
+ * cannot be found, WebWork would fall back and use the default message. An example would be as follows :-
+ * <pre>
+ *   &lt;field-validator type="required"&gt;
+ *      &lt;message key="required.field"&gt;This field is required.&lt;/message&gt;
+ *   &lt;/field-validator&gt;
+ * </pre>
+ * or
+ * <pre>
+ *   &lt;validator type="expression"&gt;
+ *      &lt;param name="expression"&gt;email.startsWith('Mark')&lt;/param&gt;
+ *      &lt;message key="email.invalid"&gt;Email needs with starts with Mark&lt;/message&gt;
+ *   &lt;/validator&gt;
+ * </pre>
+ *
+ *
+ * <!-- END SNIPPET: i18n -->
+ *
+ *
  * @author Jason Carreira
  * @author tmjee
  *