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.:)

Recommended Answers

All 5 Replies

>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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.