Vadim Gritsenko dijo:

Hi Vadim:

I got the idea. But I cannot see a "case" where we need a widget level
plugged validator that cannot be resolved by the form level validator.

In fact, the idea that woody first validate at the widget level is good
because that way we can be sure that we got the right object or NULL on
the widgets just before we start our custom validation.

On the other way, I understand your need for a java validator from the
performance view of the overall validation process.

If we will manage validations at the widget level, then there is not clear
when the widget validator will happen. Sample:

suppose we have 3 widgets: A, B and C. And we need a custom widget level
validation in C that depends on the current values of A and B. Similar as
the sample posted.

The question is: When woody will "call" my custom widget validator of C?

The probable answer are:

1-At first, when A and B are still not refreshed from the form.
2-Based on the order of widgets in definition or template file. Here can
also be a similar case for some widgets as (1).
3-Right after woody did all defined validations on the definition file.
4-As they comes.

Of course here we need first define a contract. At least if we choose (3)
then we already have a way to do this. (3) is similar as we can do it
right now.

WDYT?

Right after reading again your post I thought we can make a new validator
called "custom" that can call a java or javascript function. But can be
better to define some widget "events" interface.

On the other way, if we will programming a custom java function and allow
form designers to "know" the internals of all the thing by giving them the
work of "code the call" our custom validatorm then it is not better to let
programmer do this at all as we currently do? I see this like a mix of
concerns.

The discussion is very interesting. At the end we want a better CForms. :-D

CaW (Comments are Welcome) Is this a new acronym? ;-)

Best Regards,

Antonio Gallardo


> No, I mean in form model itself. To give you context:
>
> <wd:form xmlns:wd="http://apache.org/cocoon/woody/definition/1.0";>
>   <wd:validation>
>     <wd:assert test="Or(IsNull(a), IsNull(b))"/>
>   </wd:validation>
>   <wd:widgets>
>     <wd:field id="a">
>       <wd:datatype base="string"/>
>     </wd:field>
>     <wd:field id="b">
>       <wd:datatype base="string"/>
>     </wd:field>
>   </wd:widgets>
> </wd:form>
>
>
>>>PS Antonio, can you attach not a Javascript, but custom Java validator
>>>to the form?
>>
>>I think this is posible, by calling a java function inside of a
>> javascript
>>function.
>
> No, I mean without Flowscript, and I mean not a Javascript form object
> but real Form class.
> org.apache.cocoon.woody.formmodel.Form does not seem to have any
> setters/getters for validators, so I presume that's not possible.
>
> Vadim
>
>

Reply via email to