Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6608689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:38:11+00:00 2026-05-25T19:38:11+00:00

i have an email field which i want to validate that it’s valid email,

  • 0

i have an email field
which i want to validate that it’s valid email, and validate that it doesn’t exist in the database, so i used for valid email pattern the @Email from hibernate in the bean:

@NotBlank(message = "{email.required}")
@Email(message = "{invalid.email}")
@Size(max = 25, message = "{long.value}")

and in the jsf page:

<f:validator binding="#{emailExistValidator}" />

my questions:

  1. What happens first, the faces validator or the bean validation ?
  2. What do you think about this mixing between bean validation and
    FacesValidator, is it bad practice,if so what do you suggest ?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:38:11+00:00Added an answer on May 25, 2026 at 7:38 pm

    1- What happens first, the faces validator or the bean validation?

    JSF conversion and validation will run first in the order it is been declared on the component, with required first. If any of it fails, then the remnant of JSF validation and all the bean validation is completely skipped, else all of the bean validation is executed.


    2- What do you think about this mixing between bean validation and FacesValidator, is it bad practice, if so what do you suggest?

    Hard to answer. It solely depends on the functional requirements and the purpose of the validator and how closely tied the validation is to the model or the view.

    If the validation needs to run everytime the model property is set (so, it’s closely tied to the model), then bean validation would be preferred. But if validation needs to run only once, e.g. during registration (so, it’s closely tied to a specific view), then JSF validation would be preferred.

    For example, if you’re checking the email syntax pattern, then bean validation would make more sense, e.g.:

    @Pattern(regexp = "([^.@]+)(\\.[^.@]+)*@([^.@]+\\.)+([^.@]+)", message = "Email is not in valid format")
    private String email;
    

    If you’re checking the email existance against the DB, then a JSF validator would make more sense since you don’t want it to unnecessarily be executed on every property set. DB calls are not cheap per se.

    Again, this is subjective. See what fits the business requirements the best. Maybe you’re required to validate it on every property set, for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a contact field which sends an email when submitted, I want
I have a database with an email field, and it cycles through the database
I have a app that searches a database and retrieves 3 fields Name, Email
I have Registration model(which has fields login, password, email, mobile) and want to use
I have a web form to which I want to take a parameter from
I have a list of all email ids which I have copied from the
I have a database in Access 2003 that I only want certain people to
In the page I'm developing I have a Email field and ConfirmEmail field. And
I have an EditText for an email field. My mobile screen is really small
I have 2 fields that looks for username, the gets the email address and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.