Hi guys,

I am just wondering: you guys have developed validwhen so we could have a
more powerful validator, right? But, while using just commons-validator in a
GUI (non-web) project, I noticed I could implement a very powerful validator
using
JXPath.

Here is the code for the static method:

   public static boolean validateJXPath(Object bean, Field field) {
      final JXPathContext ctx = JXPathContext.newContext(bean);

      return
!Boolean.FALSE.equals(ctx.getValue(field.getVarValue("jxpath")));
   }

Notice it's just a simple validator with no dependencies on
HttpServletRequest or ActionErrors. I don't know that much about validwhen,
but from what I've seen, XPath expressions can do everything validwhen
expressions can and even more.

Am I missing something? Is there any reason why a JXPath-based validator as
the above wouldn't be suitable for Struts?

Regards,
Michael Nascimento Santos
JSR 207 Expert Group Member
http://today.java.net/pub/au/80
Sun Certified Programmer for the Java 2 Platform 1.4
Sun Certified Web Component Developer for J2EE
Moderador SouJava - http://www.soujava.org.br

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

Reply via email to