Search |
||
Trying out JBoss' Seam (Continued)Posted by bleonard on May 30, 2006 at 12:55 PM PDT
In my previous blog entry I converted a standard JSF / EJB 3.0 application to one that uses JBoss' Seam framework. I covered Seam's primary feature, direct integration of JSF with EJB 3.0, eliminating the Managed Bean. In this entry, I'm going to show off Seam's validation support. Getting Started
Adding ValidationIn our simple registration application, we currently have 3 fields, 2 of which have a required length and a third which just can't be null. These constraints are currently managed in our view. For example, for username: One obvious weakness to this approach is that any alternative views (MIDlet, Rich Client) would require implementation of the same constraints. The Seam framework allows us to specify these constraints on the model directly. Seam incorporates the Hibernate Validator framework, which works regardless of your persistence provider. So for example, on the username property of our User entity, we can specify the following: Try the following:
AddendumIn order to display individual component messages, you just need to assign an HtmlMessage component to each of the input fields in your JSP. Note, for the association to work, you also have to add an id property to each of the input fields. Finally, notice the globalOnly property added to the HtmlMessages component. This prevents the individual component messages from being displayed twice.
I should also point out that since writing this blog I have learned that the @IfInvalid annotation has been deprecated. Support for the new s:validateAll and s:validate JSF tags will be in the next binary release of Seam, I assume 1.0.0CR4. »
Related Topics >>
Netbeans Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|