Hi I am thinking of extending (hacking) antlr classes that are distributed with commons validator. I am wondering if this idea should point to struts instead of commons validator. In validwhen validator you are able to write quite complicated conditions, but the real problem for me is using validwhen test expressions when comparing with values which are java constants. Let's assume that we have 2 html widgets one is html select called "transportMean" and the second is text field component called "numberOfTires". For html select values i have a list of lavel value beans where values are java constants. So i have: new LabelValueBean("car", foo.bar.CAR_TYPE); new LabelValueBean("plane", foo.bar.PLANE_TYPE);
We have the following transportMeans: car, plane, train, bike, etc. I would like to have my validator to check if numberOfTires field is integer only if value of transportMean is car or bike. If i use validwhen validar i will have to write test expression to compare value of tranportmean with value of foo.bar.CAR_TYPE ! And when value of foo.bar.CAR_TYPE changes i also need to modify my validation. I am thinking of using additional syntax to antlr expression to let it recognize java constants expressions. In Cocoon framework to reference constant they use full package name of constant prefixed by "Package" keyword. So this time you can use syntax like: <test> transportMean = Packages.foo.bar.CAR_TYPE </test> What do you think of this idea? Maybe someone has already done it?? I am waiting for your opinions.