This week's book giveaway is in the Security forum.
We're giving away four copies of Penetration Testing Basics and have Ric Messier on-line!
See this thread for details.
Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom Validator persistently returning NULL

Abhishek Dwaraki
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a custom validator in my application. Defined and registered in faces-config.xml. The code is below.

public void validate(FacesContext context, UIComponent component,
Object value) throws ValidatorException {
// TODO Auto-generated method stub
String nameValue;

if (value == null)
nameValue = value.toString();

if ((isEmptyOrShort(nameValue))) {
FacesMessage message = new FacesMessage("Validation Error occured",
"Field" + nameValue + "is required or is too short");

validationStatus = "Failure";

throw new ValidatorException(message);
validationStatus = "Success";


private static boolean isEmptyOrShort(String value) {
if (value.equals("") || (value.length() < 3 || value.length() > 10) || value == null)
return true;
return false;

public String returnValidationStatus() {
System.out.println("Inside LoginValidator");
return validationStatus;

The point is to return a value to the jsf page so that it can be dynamically validated. The validate function cannot be directly called from the jsf tag on my jsp page. So I have created an object of the validator class in my Backing Bean and am trying to access the method. It is persistently returning null. Please advise as to wat the problem might be.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic