You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Holzmueller <ho...@mailgrab.exedio.com> on 2020/10/20 15:57:58 UTC
Under certain circumstances, prevent the replacement of markup after
a successful Ajax response
Hi everyone,
I've a question about the wicket ajax response processing.
What's the meaning behind the attrs.wr JavaScript boolean attribute?
I can change it with JavaScript by the IAjaxCallListener.getBeforeSendHandler() method.
My goal is to prevent the ajax component replacement in some circumstances.
The IAjaxCallListener.getPrecondition() is to early. The circumstances could be changed during the delay between request and response.
Thanks for any help.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Under certain circumstances, prevent the replacement of markup
after a successful Ajax response
Posted by Sven Meier <sv...@meiers.net>.
Hi,
> By inactivity, I could also only refresh only the info box without the form
that's the correct solution.
Updating a text component (or its parent) via Ajax while it has focus will lead to jumping cursors and/or lost user input.
Have fun
Sven
On 21.10.20 09:35, Holzmueller wrote:
> Hi,
>
> thanks for your feedback.
>
> My use-case is a text input field, that submits the form data on blur. But also after an timespan of inactivity in the input filed itself (user stopped writing).
> The ajax response refreshed the form (invalidation messages) and in addition to that an info box. Of course, the form refresh replaces the current input field (that's the problem).
>
> By inactivity, I could also only refresh only the info box without the form. This could be a solution and maybe it is good enough.
>
> An other approach (still updating the form) is to store and restore the value (and focus, and cursor position) of the input field. I could use AjaxRequestTarget.prependJavaScript() and AjaxRequestTarget.appendJavaScript() for that.
>
> I think I will try one of those two solutions.
>
> Thanks for the help.
>
>
>
> Am 20.10.20 um 20:06 schrieb Sven Meier:
>> Hi,
>>
>> from the JavaDoc:
>>
>> /**
>> * Indicates whether or not this AjaxBehavior will produce <ajax-response>. By default it will
>> * produce it but some behaviors may need to return their own response which shouldn't be
>> * processed by wicket-ajax.js
>> */
>> private boolean wicketAjaxResponse = true;
>>
>> So with wicketAjaxResponse = false (attrs.wr = false) you can specify that your code wants to handle the Ajax response instead of Wicket's default handling (i.e. changing the DOM).
>>
>>> My goal is to prevent the ajax component replacement in some circumstances.
>>> The circumstances could be changed during the delay between request and response.
>> I don't see a solution how you could change .wr dynamically, since no event is published before handling of the Ajax response.
>>
>> What's your use-case?
>>
>> Have fun
>> Sven
>>
>>
>> On 20.10.20 17:57, Holzmueller wrote:
>>> Hi everyone,
>>>
>>> I've a question about the wicket ajax response processing.
>>> What's the meaning behind the attrs.wr JavaScript boolean attribute?
>>>
>>> I can change it with JavaScript by the IAjaxCallListener.getBeforeSendHandler() method.
>>>
>>> My goal is to prevent the ajax component replacement in some circumstances.
>>>
>>> The IAjaxCallListener.getPrecondition() is to early. The circumstances could be changed during the delay between request and response.
>>>
>>> Thanks for any help.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Under certain circumstances, prevent the replacement of markup
after a successful Ajax response
Posted by Holzmueller <ho...@mailgrab.exedio.com>.
Hi,
thanks for your feedback.
My use-case is a text input field, that submits the form data on blur. But also after an timespan of inactivity in the input filed itself (user stopped writing).
The ajax response refreshed the form (invalidation messages) and in addition to that an info box. Of course, the form refresh replaces the current input field (that's the problem).
By inactivity, I could also only refresh only the info box without the form. This could be a solution and maybe it is good enough.
An other approach (still updating the form) is to store and restore the value (and focus, and cursor position) of the input field. I could use AjaxRequestTarget.prependJavaScript() and AjaxRequestTarget.appendJavaScript() for that.
I think I will try one of those two solutions.
Thanks for the help.
Am 20.10.20 um 20:06 schrieb Sven Meier:
> Hi,
>
> from the JavaDoc:
>
> /**
> * Indicates whether or not this AjaxBehavior will produce <ajax-response>. By default it will
> * produce it but some behaviors may need to return their own response which shouldn't be
> * processed by wicket-ajax.js
> */
> private boolean wicketAjaxResponse = true;
>
> So with wicketAjaxResponse = false (attrs.wr = false) you can specify that your code wants to handle the Ajax response instead of Wicket's default handling (i.e. changing the DOM).
>
> >My goal is to prevent the ajax component replacement in some circumstances.
> >The circumstances could be changed during the delay between request and response.
>
> I don't see a solution how you could change .wr dynamically, since no event is published before handling of the Ajax response.
>
> What's your use-case?
>
> Have fun
> Sven
>
>
> On 20.10.20 17:57, Holzmueller wrote:
>> Hi everyone,
>>
>> I've a question about the wicket ajax response processing.
>> What's the meaning behind the attrs.wr JavaScript boolean attribute?
>>
>> I can change it with JavaScript by the IAjaxCallListener.getBeforeSendHandler() method.
>>
>> My goal is to prevent the ajax component replacement in some circumstances.
>>
>> The IAjaxCallListener.getPrecondition() is to early. The circumstances could be changed during the delay between request and response.
>>
>> Thanks for any help.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Under certain circumstances, prevent the replacement of markup
after a successful Ajax response
Posted by Sven Meier <sv...@meiers.net>.
Hi,
from the JavaDoc:
/**
* Indicates whether or not this AjaxBehavior will produce
<ajax-response>. By default it will
* produce it but some behaviors may need to return their own
response which shouldn't be
* processed by wicket-ajax.js
*/
private boolean wicketAjaxResponse = true;
So with wicketAjaxResponse = false (attrs.wr = false) you can specify
that your code wants to handle the Ajax response instead of Wicket's
default handling (i.e. changing the DOM).
>My goal is to prevent the ajax component replacement in some
circumstances.
>The circumstances could be changed during the delay between request
and response.
I don't see a solution how you could change .wr dynamically, since no
event is published before handling of the Ajax response.
What's your use-case?
Have fun
Sven
On 20.10.20 17:57, Holzmueller wrote:
> Hi everyone,
>
> I've a question about the wicket ajax response processing.
> What's the meaning behind the attrs.wr JavaScript boolean attribute?
>
> I can change it with JavaScript by the IAjaxCallListener.getBeforeSendHandler() method.
>
> My goal is to prevent the ajax component replacement in some circumstances.
>
> The IAjaxCallListener.getPrecondition() is to early. The circumstances could be changed during the delay between request and response.
>
> Thanks for any help.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org