I am not a fan of javascript, I know, I can use this, but I have always had browser compatibility issues with javascript. I still use javascript, when absolutely necessary, but I prefer to avoid it.

As far as "required" goes, that probably won't work because I could have a string like " test " which would pass the "required test, wouldn't it? unless I misunderstood what you are suggesting.

I did try a generic loop as per Joe's suggestion and that worked pretty well. Here is a what I did.

java.util.Map map = thisForm.getMap();
java.util.Iterator it = map.keySet().iterator();
while(it.hasNext()){
 String key = (String) it.next();
 Object obj = map.get(key);
 if (obj instanceof String){
   obj = ((String) obj).trim();
 }
 else if(obj instanceof String[]){
    String[] temp = (String[]) obj;
    for(int i=0;i<temp.length; i++){
      temp[i] = temp[i].trim();
    }
   obj = temp;
 }
map.put(key, obj);
}


From: Kishore Senji <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: Struts Users Mailing List <user@struts.apache.org>
Subject: Re: Trim all fields before validation
Date: Thu, 1 Sep 2005 09:40:42 -0700

Wouldn't this be easier, without mucking with the form, to let this be
handled by the validator itself. For any field validation you would just
have to have the "requires" validation before you do any other validation,
and that way you would take care of empty strings or as Joe said you could
do this in javascript as well pretty easily.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to