Hi,

There’s no reliable way to do so as all requests arrive simultaneously on
the server side, so unless you do a distributed lock — which is not a good
idea usually — there’s no way to do so.

One of ideas is: you could pass sequential number with every request, put
that number in a storage (like Redis) using compare and set, and if request
is older than the one already in storage — do nothing.

Usually such requests are throttled on the client side, I.e.:
https://github.com/cowboy/jquery-throttle-debounce

On Friday, June 7, 2019, Svein-Erik Løken <se.lo...@brav.com> wrote:

> When typing "test" pretty fast into textfield id=nameFilter the result is
> wrong. I am typical getting "DEBUG nameFilter: te" (sometimes just "t").
> The grid data corresponds to the nameFilter output.
>
> The output from  getNamefilterDebug() is always:
> getNamefilterDebug: t
> getNamefilterDebug: te
> getNamefilterDebug: tes
> getNamefilterDebug: test
>
>
>
> <t:form t:id="nameFilterForm" id="nameFilterForm" async="true"
> autofocus="true" style="display:flex;align-items: center;">
>     <t:label for="nameFilter">Name:</t:label>
>     <t:textfield t:id="nameFilter" oninput="$(this).closest('form').submit()"
> style="vertical-align: top" value="nameFilter" autocomplete="off"/>
>     <t:zone t:id="destinationCountZone">${destinationBeans.size()}</t:
> zone>
> </t:form>
>
> <t:zone t:id="destinationTableZone">
>     DEBUG nameFilter: ${namefilterDebug}
>
>     <t:grid renderTableIfEmpty="true" style="width:auto"
> source="destinationBeans" rowClass="prop:rowClass" class="table table-hover
> table-bordered" t:row="destinationBean" model="model" rowsPerPage="1000"
> t:pagerPosition="top">
>
>
> void onSubmitFromNameFilterForm() {
>     applyFilter();
>     ajaxResponseRenderer.addRender(destinationTableZone);
> }
>
>
> public String getNamefilterDebug() {
>     System.err.format("getNamefilterDebug: %s%n",nameFilter);
>     return nameFilter;
> }
>
>
> When using JavaScript/React I just call XMLHttpRequest.abort() for all
> ongoing XHR's.
>
>
> I cannot figure out how to do this in Tapestry 5.4.4. I was looking for
> AjaxResponseRenderer addRender(ClientBodyElement zone, abortPrevious);
>
> S-E
>
>
>
>

-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Reply via email to