|
Project Information
Featured
Downloads
Links
|
BlogFuture updates will be here, at this blog. Questions and DiscussionsAny questions, comments, or concerns should be directed to the Issues tab or to the discussion group here. (Not deep inside wiki pages.) DemoFinally, there is now a demo available here. You can find the source code for the demo available here. There is now (as of r231) support for internationalization and message interpolation. This can be shown in action in the sample. SummaryThis project began as a response to this issue in the GWT issue tracker. Currently this project is written against Java 6 to provide the most current features. This project supports the 2.1 branch of GWT and above. The purpose is to provide an annotation based solution to both client side and server side validation. As of milestone 2.0 we aim to be compliant with the JSR-303 specification mandatory sections. Currently the library supports the following:
For further information on features see the development roadmap. Using this projectYou will first need the dependencies needed to use this project on your classpath. You will also need the gwt-validation version 2.0 jar on your classpath. Then you will need to add the following to your Module.gwt.xml file in your gwt project. <inherits name='com.em.validation.Validation' /> Then you can use the framework in a JSR-303 compliant manner, as shown below. public class Person {
@Size(min=1)
@NotNull
private String lastName;
@NotNull
@Size(min=3)
private String firstName;
public String getLastName() { return this.lastName; }
public String getFirstName() { return this.firstName; }
public void setLastName(String lastName) { this.lastName = lastName; }
public void setFirstName(String firstName) { this.firstName = firstName; }
@Pattern(regexp="(.*), (.*)")
public String getFullName() {
return this.lastName + ", " + this.firstName;
}
}At this point the user can begin to use the validation framework. First they will need a ValidatorFactory which can be easily built with the default method. ValidatorFactory factory = Validation.byDefaultProvider().configure().buildValidatorFactory(); Once the factory has been created, individual validators can be built. In this case, for the person factory. Because of the "magic" of deferred binding in version 2.0, the same code is used on the client and server side. Person p = new Person(); Validator validator = factory.getValidator(); Set<ConstraintViolation<Person>> violations = validator.validate(p); Stats!
|