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 3609704
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:39:41+00:00 2026-05-18T21:39:41+00:00

HI, I want to know how to implement Validator in JSF. What is the

  • 0

HI,

I want to know how to implement Validator in JSF. What is the advantages of declaring the validator-id. When it will be called in the life cycle?. I have implemented the following code. Please find out what is wrong in the code. I am not seeing it called anywhere in the life cycle.

   <?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
  "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
  "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config>
 <lifecycle>
  <phase-listener>javabeat.net.jsf.JsfPhaseListener</phase-listener>
 </lifecycle>
 <validator>
  <validator-id>JsfValidator</validator-id>
  <validator-class>javabeat.net.jsf.JsfValidator</validator-class>
 </validator>

 <managed-bean>
  <managed-bean-name>jsfBean</managed-bean-name>
  <managed-bean-class>javabeat.net.beans.ManagedBean</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
 </managed-bean>
 <navigation-rule>
  <navigation-case>
   <from-outcome>success</from-outcome>
   <to-view-id>success.jsp</to-view-id>
  </navigation-case>
 </navigation-rule>
</faces-config>


public class JsfValidator implements Validator {

 public JsfValidator()
 {
  System.out.println("Inside JsfValidator Constructor");
 }
 @Override
 public void validate(FacesContext facesContext, 
       UIComponent uiComponent, 
       Object object)
   throws ValidatorException {
  System.out.println("Inside Validator");
 }
}
  • 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-18T21:39:41+00:00Added an answer on May 18, 2026 at 9:39 pm

    You have to tie this custom validator to some jsf component on the jsf page, and that is where the vaidator-id you have defined is used. for e.g your jsf page might look something like this

    <h:inputText id="myInput" value="#{mybean.property}">
         <f:validator validatorId="JsfValidator"/>
    </h:inputText>
    

    If you are learning jsf validation and conversion then I strongly recommend you to go through this article which clearly explains with examples on in which jsf life cycle phase the validation happens etc.

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

Sidebar

Related Questions

I know it's simple to implement, but I want to reuse something that already
I want to know, how sockets are implemented in the Java Virtual Machine. Is
I want to know how to implement logic for my download button in PHP.
i am trying to implement routing on my website. and just want to know
I want to implement the following validation. Match at least 5 digits and also
I have my own password/login rules that I want to implement such as: Password:
Want to know what the stackoverflow community feels about the various free and non-free
I want to know what a virtual base class is and what it means.
I want to know what are the options to do some scripting jobs in
I want to know what exactly is the sequence of calls that occurs when

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.