File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Custom Validator persistently returning NULL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom Validator persistently returning NULL" Watch "Custom Validator persistently returning NULL" New topic
Author

Custom Validator persistently returning NULL

Abhishek Dwaraki
Ranch Hand

Joined: Feb 13, 2006
Posts: 44
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)
return;
else
nameValue = value.toString();

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

validationStatus = "Failure";

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

}

private static boolean isEmptyOrShort(String value) {
if (value.equals("") || (value.length() < 3 || value.length() > 10) || value == null)
return true;
else
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.


Regards,
Abhishek Dwaraki
Dept of Electrical and Comp Engg
University of Massachusetts, Amherst
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom Validator persistently returning NULL
 
Similar Threads
Problem jsf cutom validation -- validate method dont call
JSF validation not validating
display error message
Custom Component : Missing Update Model Phase?
Custom validator not validating