You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by g kuczera <gk...@gmail.com> on 2017/03/27 08:36:52 UTC

Finding out when actionLink action is completed on the user side

Hi everybody,
I have an actionLink, which action returns the pdf document from the
server. The document is dynamically generated, so it can take few seconds
to deliver it to the user. I want to prevent the user from clicking on the
actionLink multiple times. I can block it in java script after the click
event occurrs, but I don't know how to find out when to unblock it.

Is there a way to find out when the document is received by the user and
then unblock the actionLink? I found one possible solution, but it seems
like an overhead:
http://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download
Is there a more tapestry way to do it?

Here is the actionLink code:
                                    <t:actionLink
t:id="downloadDocumentAsPdf" context="document.document_id"
                                        target="_blank">
                                        ${message:download.document.as.pdf}
                                    </t:actionLink>

Re: Finding out when actionLink action is completed on the user side

Posted by Christian Riedel <cr...@googlemail.com>.
Sure, the equivalent in 5.3 is to use t:zone or better: write a mixin and add a custom listener to your link.
I once wrote a very generic mixin that you can use as click or change (or any event) listener:

https://gist.github.com/criedel/315d0cf8dab312870a7bc0d184ef0dd4

I think there are also similar examples to be found here: http://jumpstart.doublenegative.com.au/jumpstart/examples/input/atonevent/0




> Am 27.03.2017 um 17:05 schrieb g kuczera <gk...@gmail.com>:
> 
> Right now we are using Tapestry 5.3.7 and upgrading is unlikely, so the
> async option is out of the reach, I think. I also do not want to open the
> save-file-dialog by default (the requirement from the client).
> 
> I will check the FileSaver as soon as I can.
> 
> Is there a possibility that the zones could be used to refresh the button
> state (changing from disabled to enabled)?
> 
> 2017-03-27 11:19 GMT+02:00 Christian Riedel <cr...@googlemail.com>:
> 
>> you could use t:async="true“ instead and return the pdf along with some
>> custom script that re-activates your button.
>> the binary of the pdf could be passed into FileSaver[0] to create the
>> save-file-dialog of the browser. while all this happens you could show a
>> progress indicator to the user.
>> 
>> if you find this too complicated you could keep the traditional requests
>> but maybe open a popup that triggers the download.
>> 
>> [0] https://github.com/eligrey/FileSaver.js
>> 
>>> Am 27.03.2017 um 10:36 schrieb g kuczera <gk...@gmail.com>:
>>> 
>>> Hi everybody,
>>> I have an actionLink, which action returns the pdf document from the
>>> server. The document is dynamically generated, so it can take few seconds
>>> to deliver it to the user. I want to prevent the user from clicking on
>> the
>>> actionLink multiple times. I can block it in java script after the click
>>> event occurrs, but I don't know how to find out when to unblock it.
>>> 
>>> Is there a way to find out when the document is received by the user and
>>> then unblock the actionLink? I found one possible solution, but it seems
>>> like an overhead:
>>> http://stackoverflow.com/questions/1106377/detect-when-
>> browser-receives-file-download
>>> Is there a more tapestry way to do it?
>>> 
>>> Here is the actionLink code:
>>>                                   <t:actionLink
>>> t:id="downloadDocumentAsPdf" context="document.document_id"
>>>                                       target="_blank">
>>>                                       ${message:download.document.
>> as.pdf}
>>>                                   </t:actionLink>
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 


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


Re: Finding out when actionLink action is completed on the user side

Posted by g kuczera <gk...@gmail.com>.
Right now we are using Tapestry 5.3.7 and upgrading is unlikely, so the
async option is out of the reach, I think. I also do not want to open the
save-file-dialog by default (the requirement from the client).

I will check the FileSaver as soon as I can.

Is there a possibility that the zones could be used to refresh the button
state (changing from disabled to enabled)?

2017-03-27 11:19 GMT+02:00 Christian Riedel <cr...@googlemail.com>:

> you could use t:async="true“ instead and return the pdf along with some
> custom script that re-activates your button.
> the binary of the pdf could be passed into FileSaver[0] to create the
> save-file-dialog of the browser. while all this happens you could show a
> progress indicator to the user.
>
> if you find this too complicated you could keep the traditional requests
> but maybe open a popup that triggers the download.
>
> [0] https://github.com/eligrey/FileSaver.js
>
> > Am 27.03.2017 um 10:36 schrieb g kuczera <gk...@gmail.com>:
> >
> > Hi everybody,
> > I have an actionLink, which action returns the pdf document from the
> > server. The document is dynamically generated, so it can take few seconds
> > to deliver it to the user. I want to prevent the user from clicking on
> the
> > actionLink multiple times. I can block it in java script after the click
> > event occurrs, but I don't know how to find out when to unblock it.
> >
> > Is there a way to find out when the document is received by the user and
> > then unblock the actionLink? I found one possible solution, but it seems
> > like an overhead:
> > http://stackoverflow.com/questions/1106377/detect-when-
> browser-receives-file-download
> > Is there a more tapestry way to do it?
> >
> > Here is the actionLink code:
> >                                    <t:actionLink
> > t:id="downloadDocumentAsPdf" context="document.document_id"
> >                                        target="_blank">
> >                                        ${message:download.document.
> as.pdf}
> >                                    </t:actionLink>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Finding out when actionLink action is completed on the user side

Posted by Christian Riedel <cr...@googlemail.com>.
you could use t:async="true“ instead and return the pdf along with some custom script that re-activates your button.
the binary of the pdf could be passed into FileSaver[0] to create the save-file-dialog of the browser. while all this happens you could show a progress indicator to the user.

if you find this too complicated you could keep the traditional requests but maybe open a popup that triggers the download.

[0] https://github.com/eligrey/FileSaver.js

> Am 27.03.2017 um 10:36 schrieb g kuczera <gk...@gmail.com>:
> 
> Hi everybody,
> I have an actionLink, which action returns the pdf document from the
> server. The document is dynamically generated, so it can take few seconds
> to deliver it to the user. I want to prevent the user from clicking on the
> actionLink multiple times. I can block it in java script after the click
> event occurrs, but I don't know how to find out when to unblock it.
> 
> Is there a way to find out when the document is received by the user and
> then unblock the actionLink? I found one possible solution, but it seems
> like an overhead:
> http://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download
> Is there a more tapestry way to do it?
> 
> Here is the actionLink code:
>                                    <t:actionLink
> t:id="downloadDocumentAsPdf" context="document.document_id"
>                                        target="_blank">
>                                        ${message:download.document.as.pdf}
>                                    </t:actionLink>


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