Carsten Ziegeler wrote:

Sylvain Wallez wrote:


This calls for binding-specific validators that know both the
application model and the form model. I proposed to add XPath predicates
to the binding for this purpose. E.g :

<wb:field id="foo-field" path="foo">
 <wb:validate>
   <wb:assert test="java:validateFoo($currentBean, $currentField/value)">
   <wi:fail-message>Business model rejects value for
"foo"</wi:fail-message>
 </wb:validate>
</wb:field>

The variables are predefined by the binding framework (this is at the
random thought state) :
- $currentBean is the bean holding the current property ("foo").
- $currentField is the "foo-field" that is currently being bound.

The "test" expression would thus call the "validateFoo" method on the
business object.



Ok, this is a possibility, but I don't like it :)
I don't want to "code" this in the xml; it could be done automatically
by some rules, like a validateXXX() method in the business model.

I agree, that your suggestion makes sense in some cases, so I would still
go for both :)



Not a problem, since <wb:assert> is just a particular implementation of Validator. So what about :
<wb:validate>
<wb:auto-validate-using-business-model/>
</wb:validate>


;-)

Sylvain

--
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com




Reply via email to