aspose file tools
The moose likes JSF and the fly likes how to compile a custom validator class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "how to compile a custom validator class" Watch "how to compile a custom validator class" New topic
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,
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to compile a custom validator class
 
Similar Threads
JTables editor/renderer ?
Trouble setting CLASSPATH variable in windows 2000 prof.
help me have a look at it
Converting Infix to Postfix Expressions
How to use validation with example need