Here is the test case import java.io.*; import java.util.*; import org.apache.commons.validator.*;
public class TestValidatorMask{ public static void main(String[] args) throws Exception { ValidatorResources vr = new ValidatorResources(getFormSetAsInputStream()); Form form = vr.getForm(Locale.US, "testForm"); Field field = form.getField("firstName"); List list = Arrays.asList(new String[]{"AA.Ñ ", ".C.ÑÑÑÑ ", " ... ABC ZÑÑ.. ", " @gÑÑÑ..Ñ."}); for(Iterator iterator=list.iterator(); iterator.hasNext();){ String value = (String)iterator.next(); System.out.println("value = "+value+" mask = "+field.getVarValue("mask")+" mapassed test? == "+validateMask(value, field.getVarValue("mask"))); } } public static boolean validateMask(String value, String mask){ return GenericValidator.matchRegexp(value, mask); } public static InputStream getFormSetAsInputStream(){ StringBuffer sb = new StringBuffer(); sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>") .append("<!DOCTYPE form-validation PUBLIC ") .append("\"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN\" ") .append("\"http://jakarta.apache.org/commons/dtds/validator_1_0.dtd\">") .append("<form-validation><global><constant><constant-name>zip</constant-name>") .append("<constant-value>^[A-Z.Ñ\\s]*$</constant-value>") .append("</constant></global><formset><form name=\"testForm\"><field property=\"firstName\" depends=\"mask\">") .append("<arg0 key=\"prompt.name\"/><var>") .append("<var-name>mask</var-name>") .append("<var-value>${zip}</var-value>") .append("</var></field></form></formset></form-validation>"); return new ByteArrayInputStream(sb.toString().getBytes()); } } On Mon, 31 Jan 2005 23:09:42 -0600, Carlos Cajina - Hotmail <[EMAIL PROTECTED]> wrote: > I just couldn't resist :^P ... Tomorrow I'll try it, but for now this looks > like a "simpler" solution to the character encoding problem: > > http://www.servletsuite.com/servlets/encflt.htm > It should be very simple to roll your own filter. The main reason to write a filter is to set the encoding before any reads from the input stream. You Just have to implement Filter and in the doFilter method set the character encoding on the request by calling request.setCharacterEncoding(string). You can have the encoding initialized as a init parameter or however you want. for more info on writing filters take a look at http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets8.html#72440 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]