| Author |
how to compile a custom validator class
|
Max Ji
Greenhorn
Joined: Mar 29, 2006
Posts: 12
|
|
Hello, am trying to compile a custom validator class but the javac compiler does not recognize the packages javax.faces.validator, javax.faces.component, etc. I get errors like "package javax.faces.validator does not exist", "package javax.faces.component does not exist", etc. Do I need to set the classpath before compiling? The class listing is below. Thank you package com.corejsf; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.validator.Validator; import javax.faces.validator.ValidatorException; public class FileNbrValidator implements Validator { public void validate(FacesContext context, UIComponent component, Object value) { if (value == null) return; String filenbr; if (value instanceof Folder) filenbr = value.toString(); if (!checksout(filenbr)) { FacesMessage message = com.corejsf.util.Messages.getMessage( "com.corejsf.messages", "badFileNumber", null); message.setSeverity(FacesMessage.SEVERITY_ERROR); throw new ValidatorException(message); } } private static boolean checkout(String buffer) { boolean foundInvalidCharacter = false; char invalidCharacter = '\0'; int i = 0; while ((i < buffer.length()) && (!foundInvalidCharacter)) { char ch = buffer.charAt(i); if ((ch < '0') || (ch > '9')) { foundInvalidCharacter = true; invalidCharacter = ch; } else if (((i == 1) || (i == 2) || (i == 3)) && (ch == '0')) { foundInvalidCharacter = true; invalidCharacter = ch; } else { i++; } } return (foundInvalidCharacter); } }
|
 |
Rajeev Ravindran
Ranch Hand
Joined: Aug 27, 2002
Posts: 455
|
|
you need to have jsf jar file in your classpath. for me its ibm-jsf.jar since im using RAD for development. Thanks,
|
 |
 |
|
|
subject: how to compile a custom validator class
|
|
|