myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthias Niehoff" <>
Subject Bean Validation (JSR 303)
Date Mon, 27 Sep 2010 11:21:58 GMT

I'm trying to realize Bean Validation. I annotated my attributes and set
Furthermore I added a h:message tag in my form. When I test the validation
nothing happens. The input is accepted (and in my case persisted).
Relevant parts of the Code:



import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Email;

public class User {
	private String nachname;
	private String vorname;
	private String userID;
	private String password;
	private String email;
	private String role;

public class UserBean {
	private User user = new User();

	public void setUser(User user) {
		this.user = user;

	public User getUser() {
		return user;

	public String save() {
		return "/admin/user/showUser.xhtml";

And last but not least: 

<h:form id="form">
	<h:messages showDetail="true" showSummary="false" />
	<h:panelGrid columns="2" id="grid">
		<h:outputLabel value="Vorname:" for="firstName" />
		<h:inputText id="firstName" value="#{userBean.user.vorname}"
		<h:outputLabel value="Nachname:" for="lastName" />
		<h:inputText id="lastName" value="#{userBean.user.nachname}"
		<h:outputLabel value="Email:" for="email" />
		<h:inputText id="email" value="#{}" />
		<h:outputLabel value="Rolle:" for="role" />
		<h:inputText id="role" value="#{userBean.user.role}" />
		<h:outputLabel value="Passwort:" for="password" />
		<h:inputSecret id="password"
value="#{userBean.user.password}" />
		<h:commandButton id="save" action="#{}"
value="Speichern" />

Did I miss a point?  I thougt it would only be annotating the Beans.

Thanks for your help!

Matthias Niehoff

View raw message