cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robin Wyles <...@robinwyles.com>
Subject Re: [CForms] validation + value-on-changed
Date Sat, 11 Feb 2006 10:21:11 GMT
Simone,

Thanks for the explanation which clarifies things greatly, and also  
explains the behavior I was seeing. In my case the validation was  
indeed being triggered by a call to the widget's getValue within my  
on-value-changed event handler. An explicit call to validate() in my  
event handler seems to work just fine - all works as expected now.

Thanks for you help,

Robin



On 10 Feb 2006, at 04:49, Simone Gianni wrote:

> Hi Robin,
> AFAIK widgets are validated in two cases :
> - When getValue is explictly called
> - When validate is called
>
> This means that in a normal form usage, they are validated :
> - If another component (say, an event listener) calls the getValue 
> () for some reason.
> - If a submit button is pressed (explicit call to validate() )
> - If an action button with validate = true is pressed (explicit  
> call to validate() )
>
> The "http submit" that happens with submit-on-change="true" or with  
> an event handler, with or without ajax, is not a "cform submit", so  
> doesn't trigger validation if not  as a side effect of something  
> else going on.
>
> You could try calling validate() explicitly from inside your event  
> handler, it could work but i've never tested it, so let me know :)
>
> Regards,
> Simone
>
> -- 
> Simone Gianni
>
>
> Robin Wyles wrote:
>
>> Hi All,
>>
>> I have a text field with custom validation and a value-on-changed   
>> event listener...
>>
>> <fd:field id="video_key" required="true">
>>     <fd:datatype base="string" />
>>     <fd:validation>
>>         <fd:javascript>
>>             return validateVideoKey(widget);
>>         </fd:javascript>
>>     </fd:validation>
>>     <fd:on-value-changed>
>>         <fd:javascript>
>>             updateFiles(event.source);
>>         </fd:javascript>
>>     </fd:on-value-changed>
>> </fd:field>
>>
>> When the value of the field changes, the custom validation is   
>> executed and if successful then my value-on-changed listener is   
>> executed also - all good. If the validation fails then my value- 
>> on- changed listener is not executed, which is (I think) also the   
>> expected behaviour.
>>
>> However, when the validation fails as a result of the value-on-  
>> changed listener being fired no validation error message is show  
>> on  the form. My custom validation sets a ValidationError on the  
>> widget,  and this gets displayed if the form is submitted with a  
>> submit  button, just not when submitted as a result of the value- 
>> on-changed.  This is true with both AJAX enabled or AJAX disabled  
>> on my form.
>>
>> Is there a way I can get the widget to display its  
>> ValidationError  after being validated as the result of the value- 
>> on-changed?
>>
>> Alternatively, and in my particular case this is preferable, is  
>> there  a way I can disable the validation before the value-on- 
>> changed on  this field?
>>
>> Thanks,
>>
>> Robin
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message