Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to compile a custom validator class  RSS feed

 
Max Ji
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to have jsf jar file in your classpath. for me its ibm-jsf.jar since im using RAD for development.

Thanks,
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!