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

  • Home
  • SEARCH
  • 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 7829195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:40:10+00:00 2026-06-02T10:40:10+00:00

It is about validation in JSF. I know that there are two way for

  • 0

It is about validation in JSF. I know that there are two way for validation

  1. Bean Validation
  2. JSF Validation

I want to write my own validation class. Is it possible to add the custom validation class to JSF beans?

I don’t want to have the validation class in my facelett. Only in Bean…

  • 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-06-02T10:40:12+00:00Added an answer on June 2, 2026 at 10:40 am

    Yes you can write your own validator class like this:

    @FacesValidator("customValidator")
    public class CustomValidator implements Validator{
    
        public void validate(FacesContext context, UIComponent component,
                Object value) throws ValidatorException {
            // do your validation here
        }
    }
    

    and use it in your facelets:

    <h:inputText value="#{myBean.myValue}">
      <f:validator validatorId="customValidator" />
    </h:inputText>
    

    Note that the content of the @FacesValidator annotation must match the validatorId attribute of f:validator.

    Furthermore jsf input elements have an validator attribute. You can use this attribute to delegate validation to a special method in you backing bean.

    with

    public void validateInput(FacesContext context, 
                              UIComponent component, Object object) {
      // your validation with 'object' here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Two stupid questions about bean validation used in JSF: How can I remove the
I know there are a lot of questions on here about email validation and
I have some questions about Bean Validation and JSF validation, currently I am using
What's the best way to go about validating that a document follows some version
Possible Duplicate: How important is W3C XHTML/CSS validation when finalizing work? I read about
I find examples and tutorials about models and about validation. And I places that
What are cons if we do not care about validation of XHTML and CSS?
i need a C# library about strict HTML validation and filtering
The following questions are about XML serialization/deserialization and schema validation for a .net library
About project: I'm trying to write CMS-like web-site on Java. Previously I used PHP

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.