cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oceatoon <t.katelb...@systheo.com>
Subject Re: Client side validation
Date Tue, 23 Nov 2004 09:53:09 GMT
>> I once proposed that validators could produce a small snippet of JS that
>> would be included in the produced page. However, this somehow mixes some
>> client-side technology in the validators which isn't a good thing.
>> 
>> So the idea now is that a validator produces an XML representation of
>> itself, which could be a simple as it's definition translated to the
>> "fi:" namespace.
>> 
>> E.g.
>> 
>> <fd:field id="foo" required="true">
>>  <fd:datatype base="integer"/>
>>  <fd:validation>
>>    <fd:range min="1" max="10"/>
>>  </fd:validation>
>> </fd:field>
>> 
>> would produce
>> <fi:field id="foo">
>>  <fi:datatype type="integer"/>
>>  <fi:validation>
>>    <fi:required>
>>    <fi:range min="1" max="10"/>
>>  </fi:validation>
>> </fi:field>
>> 
>> It's then the job of the presentation XSLs to transform <fi:range> into
>> something useful.
Yes but isn't this restrained to very simple validations?
>> 
>> Only those validators where a client-side implementation is possible
>> would produce an XML fragment in the <fi:validation> element.
>>
> yep, that's the way to go! If widgets produced Javascript themselves, we
> would mix concerns because not all clients support Javascript or you need
> different Javascript "dialects" for different clients. 
Is different JS really coded for different browsers? I thought there were
only those with JS and those without, in the second case validation would
go back to Server Side but no different version of scripts   

> Following Sylvain's 
> proposal it's the stylesheet's job to create working valdiation programms.
> 
> We should also think of a way how and where we can add custom client-side
> validators. If we add this to the form defintion we would need some kind
> of abstract language, or at least Javascript with an abstract object
> model:
Yes, but we could also directly code the outcoming code, therefore no
generalised translation, no limits of complexity in CJS, and a brut copy of
the JS snippet into xhtml using the XSL if fi:CJS exist
> 
> <ft:client-side-validation>
>    if($widgetXY.value$ <= $widgetZZ.value$ {
> return "i18:value-to-high";
>    }
>    return true;
> </ft:client-side-validation>
CJS validation is in the template in this case, why not keep it in the model 
 <fd:validation>
    <fd:range min="1" max="10"/>
  </fd:validation>
<fd:cjsvalidation>
    if(this.value >= 1 and this.value <= 10) { 
        return "cocoricco";
    }
</fd:cjsvalidation>
(This translation could be done in the stylesheet by translating the server
validation as Luca Garulli proposed but this is restrained to the basic
valdiation rules)

or
for widgetXY for your example
<fd:cjsvalidation>
    if(this.value >= forms_getForm(widgetZZ).widgetZZ.vlue) { 
        return "cocoricco";
    }
</fd:cjsvalidation>

Regards,
Tibor





Mime
View raw message