You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Francois Meillet <fr...@gmail.com> on 2015/02/18 11:35:38 UTC

form AjaxFormComponentUpdatingBehavior validation

Hi All,


1) I have a Form with a Textfield which has a AjaxFormComponentUpdatingBehavior (blur)

When the entire form is submitted (via an AjaxButton) 
the ajaxFormComponentUpdatingBehavior.onEvent() is called
then the formComponent.validate() is called
and then when the form.validate() is called
formComponent.validate() is called again.

Could it possible to avoid this double validation ?
Do I have to override AjaxFormComponentUpdatingBehavior.onEvent()  ? ... or there is a simple way to do this ?



2) is it possible to remove a formComponent's validator just after the button.submit() and before the form.onFormSubmitted() is called



3) When the I leave a page (without submitting) with a formComponent which has a AjaxFormComponentUpdatingBehavior (blur),
the ajaxFormComponentUpdatingBehavior.onEvent() is called and then the validation.
Can I avoid the ajaxFormComponentUpdatingBehavior.onEvent()  ?


Best regards
François Meillet







Re: form AjaxFormComponentUpdatingBehavior validation

Posted by Francois Meillet <fr...@gmail.com>.
OnDomReadyHeaderItem.forScript('Thanks Sven')

I also added OnEventHeaderItem.forScript("window", "onunload", "mousedownHappened = true")
to the button.


Everything work nicely except when an onunload event is fired and the textfield is empty.
In this case the ajaxFormComponentUpdatingBehavior.onEvent() is called
and the formComponent.validate();


François Meillet






Le 18 févr. 2015 à 16:36, Sven Meier <sv...@meiers.net> a écrit :

> I didn't try it, but this would be the rough equivalent of http://stackoverflow.com/a/13729993/1041336 in Wicket:
> 
> textField.add(new AjaxFormComponentUpdatingBehavior("blur") {
>  updateAjaxAttributes(ara) {
>    ara.getAjaxCallListeners().add(new AjaxCallListener() {
>      getPrecondition() {
>        return "return |mousedownHappened| === false; ";
>      }
>    });
>  }
> });
> 
> button.add(new Behavior() {
>  renderHead(c, r) {
>    r.render(OnDomReaderHeaderItem.forScript("$(" + c.getMarkupId() + ").on('mousedown', function() { mousedownHappened = true });");
>  }
> });
> 
> Regards
> Sven
> 
> 
> On 18.02.2015 15:59, Francois Meillet wrote:
>> Thanks Sven,
>> 
>> yes this is a javascript issue.
>> 
>> I look for a nice way (a la Wicket) to disable the blur event when onunload and onclick are fired.
>> 
>> François Meillet
>> 
>> 
>> 
>> 
>> 
>> Le 18 févr. 2015 à 12:40, Sven Meier <sv...@meiers.net> a écrit :
>> 
>>> Hi,
>>> 
>>> this is rather a JavaScript issue:
>>> 
>>> http://stackoverflow.com/questions/13729837/jquery-stop-blur-event-when-clicking-submit-button
>>> 
>>> Regards
>>> Sven
>>> 
>>> On 18.02.2015 11:35, Francois Meillet wrote:
>>>> Hi All,
>>>> 
>>>> 
>>>> 1) I have a Form with a Textfield which has a AjaxFormComponentUpdatingBehavior (blur)
>>>> 
>>>> When the entire form is submitted (via an AjaxButton)
>>>> the ajaxFormComponentUpdatingBehavior.onEvent() is called
>>>> then the formComponent.validate() is called
>>>> and then when the form.validate() is called
>>>> formComponent.validate() is called again.
>>>> 
>>>> Could it possible to avoid this double validation ?
>>>> Do I have to override AjaxFormComponentUpdatingBehavior.onEvent()  ? ... or there is a simple way to do this ?
>>>> 
>>>> 
>>>> 
>>>> 2) is it possible to remove a formComponent's validator just after the button.submit() and before the form.onFormSubmitted() is called
>>>> 
>>>> 
>>>> 
>>>> 3) When the I leave a page (without submitting) with a formComponent which has a AjaxFormComponentUpdatingBehavior (blur),
>>>> the ajaxFormComponentUpdatingBehavior.onEvent() is called and then the validation.
>>>> Can I avoid the ajaxFormComponentUpdatingBehavior.onEvent()  ?
>>>> 
>>>> 
>>>> Best regards
>>>> François Meillet
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> 
>> 
> 


Re: form AjaxFormComponentUpdatingBehavior validation

Posted by Sven Meier <sv...@meiers.net>.
I didn't try it, but this would be the rough equivalent of 
http://stackoverflow.com/a/13729993/1041336 in Wicket:

textField.add(new AjaxFormComponentUpdatingBehavior("blur") {
   updateAjaxAttributes(ara) {
     ara.getAjaxCallListeners().add(new AjaxCallListener() {
       getPrecondition() {
         return "return |mousedownHappened| === false; ";
       }
     });
   }
});

button.add(new Behavior() {
   renderHead(c, r) {
     r.render(OnDomReaderHeaderItem.forScript("$(" + c.getMarkupId() + 
").on('mousedown', function() { mousedownHappened = true });");
   }
});

Regards
Sven


On 18.02.2015 15:59, Francois Meillet wrote:
> Thanks Sven,
>
> yes this is a javascript issue.
>
> I look for a nice way (a la Wicket) to disable the blur event when onunload and onclick are fired.
>
> François Meillet
>
>
>
>
>
> Le 18 févr. 2015 à 12:40, Sven Meier <sv...@meiers.net> a écrit :
>
>> Hi,
>>
>> this is rather a JavaScript issue:
>>
>> http://stackoverflow.com/questions/13729837/jquery-stop-blur-event-when-clicking-submit-button
>>
>> Regards
>> Sven
>>
>> On 18.02.2015 11:35, Francois Meillet wrote:
>>> Hi All,
>>>
>>>
>>> 1) I have a Form with a Textfield which has a AjaxFormComponentUpdatingBehavior (blur)
>>>
>>> When the entire form is submitted (via an AjaxButton)
>>> the ajaxFormComponentUpdatingBehavior.onEvent() is called
>>> then the formComponent.validate() is called
>>> and then when the form.validate() is called
>>> formComponent.validate() is called again.
>>>
>>> Could it possible to avoid this double validation ?
>>> Do I have to override AjaxFormComponentUpdatingBehavior.onEvent()  ? ... or there is a simple way to do this ?
>>>
>>>
>>>
>>> 2) is it possible to remove a formComponent's validator just after the button.submit() and before the form.onFormSubmitted() is called
>>>
>>>
>>>
>>> 3) When the I leave a page (without submitting) with a formComponent which has a AjaxFormComponentUpdatingBehavior (blur),
>>> the ajaxFormComponentUpdatingBehavior.onEvent() is called and then the validation.
>>> Can I avoid the ajaxFormComponentUpdatingBehavior.onEvent()  ?
>>>
>>>
>>> Best regards
>>> François Meillet
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>


Re: form AjaxFormComponentUpdatingBehavior validation

Posted by Francois Meillet <fr...@gmail.com>.
Thanks Sven,

yes this is a javascript issue.

I look for a nice way (a la Wicket) to disable the blur event when onunload and onclick are fired.

François Meillet





Le 18 févr. 2015 à 12:40, Sven Meier <sv...@meiers.net> a écrit :

> Hi,
> 
> this is rather a JavaScript issue:
> 
> http://stackoverflow.com/questions/13729837/jquery-stop-blur-event-when-clicking-submit-button
> 
> Regards
> Sven
> 
> On 18.02.2015 11:35, Francois Meillet wrote:
>> Hi All,
>> 
>> 
>> 1) I have a Form with a Textfield which has a AjaxFormComponentUpdatingBehavior (blur)
>> 
>> When the entire form is submitted (via an AjaxButton)
>> the ajaxFormComponentUpdatingBehavior.onEvent() is called
>> then the formComponent.validate() is called
>> and then when the form.validate() is called
>> formComponent.validate() is called again.
>> 
>> Could it possible to avoid this double validation ?
>> Do I have to override AjaxFormComponentUpdatingBehavior.onEvent()  ? ... or there is a simple way to do this ?
>> 
>> 
>> 
>> 2) is it possible to remove a formComponent's validator just after the button.submit() and before the form.onFormSubmitted() is called
>> 
>> 
>> 
>> 3) When the I leave a page (without submitting) with a formComponent which has a AjaxFormComponentUpdatingBehavior (blur),
>> the ajaxFormComponentUpdatingBehavior.onEvent() is called and then the validation.
>> Can I avoid the ajaxFormComponentUpdatingBehavior.onEvent()  ?
>> 
>> 
>> Best regards
>> François Meillet
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


Re: form AjaxFormComponentUpdatingBehavior validation

Posted by Sven Meier <sv...@meiers.net>.
Hi,

this is rather a JavaScript issue:

http://stackoverflow.com/questions/13729837/jquery-stop-blur-event-when-clicking-submit-button

Regards
Sven

On 18.02.2015 11:35, Francois Meillet wrote:
> Hi All,
>
>
> 1) I have a Form with a Textfield which has a AjaxFormComponentUpdatingBehavior (blur)
>
> When the entire form is submitted (via an AjaxButton)
> the ajaxFormComponentUpdatingBehavior.onEvent() is called
> then the formComponent.validate() is called
> and then when the form.validate() is called
> formComponent.validate() is called again.
>
> Could it possible to avoid this double validation ?
> Do I have to override AjaxFormComponentUpdatingBehavior.onEvent()  ? ... or there is a simple way to do this ?
>
>
>
> 2) is it possible to remove a formComponent's validator just after the button.submit() and before the form.onFormSubmitted() is called
>
>
>
> 3) When the I leave a page (without submitting) with a formComponent which has a AjaxFormComponentUpdatingBehavior (blur),
> the ajaxFormComponentUpdatingBehavior.onEvent() is called and then the validation.
> Can I avoid the ajaxFormComponentUpdatingBehavior.onEvent()  ?
>
>
> Best regards
> François Meillet
>
>
>
>
>
>
>


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