[jboss-cvs] jboss-seam/doc/reference/en/modules ...
Peter Muir
peter at bleepbleep.org.uk
Fri Apr 13 12:14:44 EDT 2007
User: pmuir
Date: 07/04/13 12:14:44
Modified: doc/reference/en/modules validation.xml
Log:
Document use of Seam message bundle in a Hibernate Validator annotation
Revision Changes Path
1.6 +192 -169 jboss-seam/doc/reference/en/modules/validation.xml
(In the diff below, changes in quantity of whitespace are not shown.)
Index: validation.xml
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/doc/reference/en/modules/validation.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- validation.xml 23 Mar 2007 22:42:36 -0000 1.5
+++ validation.xml 13 Apr 2007 16:14:44 -0000 1.6
@@ -246,7 +246,7 @@
</h:form>]]></programlisting>
<para>
- As a final note, it's better style to define explicit ids for
+ It's better style to define explicit ids for
important controls on the page, especially if you want to do
automated testing for the UI, using some toolkit like
Selenium. If you don't provide explicit ids, JSF will generate
@@ -276,5 +276,28 @@
</h:form>]]></programlisting>
+ <para>
+ And what if you want to specify a different message to be
+ displayed when validation fails? You can use the Seam message
+ bundle (and all it's goodies like el expressions inside the message,
+ and per-view message bundles) with the Hibernate Validator:
+ </para>
+
+<programlisting><![CDATA[public class Location {
+ private String name;
+ private String zip;
+
+ // Getters and setters for name
+
+ @NotNull
+ @Length(max=6)
+ @ZipCode(message="#{messages['location.zipCode.invalid']}")
+ public String getZip() { return zip; }
+ public void setZip(String z) { zip = z; }
+}]]></programlisting>
+
+<programlisting>
+location.zipCode.invalid = The zip code is not valid for #{location.name}
+</programlisting>
</chapter>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list