logo

JSF & PrimeFaces & Spring tutorial 15: JSF Validation With Hibernate Validator

Validating domain objects with JSF and Hibernate Validation (Bean Validation)

download result: https://app.box.com/s/arrfjgklhqp2xr8gmmpi

pom.xml:
<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-validator</artifactId>
		<version>5.1.3.Final</version>
</dependency>
Check:
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.URL;

import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
public class Check {

	@Id
	@GeneratedValue
	private int id;

	@Size(min = 1, message = "Name cannot be empty!")
	private String name;

	@Size(min = 1, message = "URL cannot be empty!")
	@URL(message = "Invalid URL!")
	private String url;

}

comments powered by Disqus

rss

Free online Java web application examples

Want to develop whole web applications which use database, security and more? See my github account, where are lot's of example projects:
github

Search