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 want to know how to implement FM Transmitter in android app. I want
I want to implement multi tenancy using Windsor and i don't know how to
I want to implement a feature in my app but I don't know the
First, I know about Clog , and I do not want to implement this
i just want to know how the call hierarchy is implemented in eclipse IDE
I have an android app it displays web view.I want know the app idle
I want to use a validation anotation. I have already a model implemented by
I want to implement the following validation. Match at least 5 digits and also
I want to implement spring3.2.0 web mvc following the example: http://programmersplanet.wordpress.com/2011/11/26/4/ but I fail.
I want to know how can we implement AJAX result in Jquery validation. For

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.