[weld-commits] Weld SVN: r5065 - doc/trunk/reference/en-US.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Sun Nov 15 19:32:41 EST 2009
Author: gavin.king at jboss.com
Date: 2009-11-15 19:32:40 -0500 (Sun, 15 Nov 2009)
New Revision: 5065
Modified:
doc/trunk/reference/en-US/example.xml
Log:
validation
Modified: doc/trunk/reference/en-US/example.xml
===================================================================
--- doc/trunk/reference/en-US/example.xml 2009-11-16 00:21:07 UTC (rev 5064)
+++ doc/trunk/reference/en-US/example.xml 2009-11-16 00:32:40 UTC (rev 5065)
@@ -24,23 +24,26 @@
<programlisting role="JAVA"><![CDATA[<h:form>
<h:panelGrid columns="2" rendered="#{!login.loggedIn}">
- <h:outputLabel for="username">Username:</h:outputLabel>
- <h:inputText id="username" value="#{credentials.username}"/>
- <h:outputLabel for="password">Password:</h:outputLabel>
- <h:inputText id="password" value="#{credentials.password}"/>
+ <f:validateBean>
+ <h:outputLabel for="username">Username:</h:outputLabel>
+ <h:inputText id="username" value="#{credentials.username}"/>
+ <h:outputLabel for="password">Password:</h:outputLabel>
+ <h:inputText id="password" value="#{credentials.password}"/>
+ </f:validateBean>
</h:panelGrid>
<h:commandButton value="Login" action="#{login.login}" rendered="#{!login.loggedIn}"/>
<h:commandButton value="Logout" action="#{login.logout}" rendered="#{login.loggedIn}"/>
</h:form>]]></programlisting>
<para>
- Users are represented by a JPA entity:
+ Users are represented by a JPA entity, with constraints defined using annotations defined by the Bean Validation
+ specification:
</para>
<programlisting role="JAVA"><![CDATA[@Entity
public class User {
- private @Id String username;
- private String password;
+ private @NotNull @Length(max=25) @Id String username;
+ private @NotNull @Length(min=6, max=20) String password;
public String getUsername() { return username; }
public void setUsername(String username) { this.username = username; }
More information about the weld-commits
mailing list