Hi,
I am developing web application using jsf2.0.
In this case, I wish to validate the email field with the help of import org.hibernate.validator.Email;
But it is not working, How to validate the email fileld...
Thank.:)
Hi,
I am developing web application using jsf2.0.
In this case, I wish to validate the email field with the help of import org.hibernate.validator.Email;
But it is not working, How to validate the email fileld...
Thank.:)
>But it is not working, How to validate the email fileld.
I want to know why your code is not working. Please post source code (bean).
import java.sql.*;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
import org.hibernate.validator.Max;
import org.hibernate.validator.Min;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Pattern;
/**
*
* @author laser
*/
@ManagedBean(name = "NewuserBean")
@RequestScoped
public class NewuserBean {
Connection con;
Statement ps;
/** Creates a new instance of NewuserBean */
public NewuserBean() {
}
private String firstname;
private String lastname;
@Email
private String email;
private String password;
private String cpassword;
private String domain;
private String message;
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getFirstname() {
return firstname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getLastname() {
return lastname;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public void setCpassword(String cpassword) {
this.cpassword = cpassword;
}
public String getCpassword() {
return cpassword;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getDomain() {
return domain;
}
}
You so realise there's no way to ensure an email address is real and "valid"?
An address entered might be correct according to some rules for some email system but invalid for another.
It might be valid for some system but not exist.
It might be valid and exist but not be reachable for whatever reason.
It might be valid, exist, and be reachable but configured to not accept incoming messages.
etc. etc. etc.
Validator interface is the main entry point to bean validation and it is super interface of Validation and ValidatorFactory classes. The easiest way is to use the static Validation.buildDefaultValidatorFactory() method.
With JSF 2, use <f:validateBean> facelets to validate a bean.
Have a look at blog - http://www.jsfsummit.com/blog/max_katz/2009/12/richfaces_with_hibernate_validator
Thanks.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.