You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by seyaw <se...@gmail.com> on 2013/11/16 10:29:25 UTC

DownloadLink and ProgressBar

Hi All,
I have a wicket DownloadLink where I generate file dynamically and download
it. It works.
The process of dynamic File generation might take some time and like to show
ProgressBar which show how much the generation has progressed. How Can I do
that.

I am using wicket 1.5.8
Thank you very much. 

 add(new DownloadLink("export", new LoadableDetachableModel<File>()
        {
            private static final long serialVersionUID =
840863954694163375L;

            @Override
            protected File load()
            {
                File exportTempDir = getGeneratedFile();
}
}



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: DownloadLink and ProgressBar

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Create a class that implements Runnable. Find how to launch a runnable
(e.g. using a thread pool). Keep a reference to this runnable and use some
property of it to track progress. Use an AJAX timer to pol for this value.


On Sun, Nov 17, 2013 at 10:14 AM, seyaw <se...@gmail.com> wrote:

> Dear Ernesto
> Thank you very much for your help. Your comments were very helpful.
> I solve the problem as you suggested with little modification
> 1. follow the reference you mention [1]
> 2. add AjaxLink that will generate a file
>
>  add(new AjaxLink("download")
>         {
>             @Override
>             public void onClick(final AjaxRequestTarget target)
>             {
>
>                 bar.start(target);
>
>                 new Thread()
>                 {
>                     public void run()
>                     {
>                         generateFile
> }.....
> 3. add a progressbar (from wicketstuff) and on its onFinsh method, trigger
> the file download
>
>  Progress = new ProgressBar("progress", new ProgressionModel()
>         {
>
>             protected Progression getProgression()
>             {
>                 return new Progression(progress);
>             }
>         })
>         {
>
>             protected void onFinished(AjaxRequestTarget target)
>             {
>                 download.initiate(target, fileName);
>             }
> progress.add(download)
> add(progress)
>
> My only problem now is I have to guess the progress of file genaration , to
> be dispalyed on the progress bar
>
> thank you very much
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451p4662463.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: DownloadLink and ProgressBar

Posted by seyaw <se...@gmail.com>.
Dear Ernesto
Thank you very much for your help. Your comments were very helpful.
I solve the problem as you suggested with little modification
1. follow the reference you mention [1]
2. add AjaxLink that will generate a file

 add(new AjaxLink("download")
        {
            @Override
            public void onClick(final AjaxRequestTarget target)
            {

                bar.start(target);

                new Thread()
                {
                    public void run()
                    {
                        generateFile
}.....
3. add a progressbar (from wicketstuff) and on its onFinsh method, trigger
the file download

 Progress = new ProgressBar("progress", new ProgressionModel()
        {

            protected Progression getProgression()
            {
                return new Progression(progress);
            }
        })
        {

            protected void onFinished(AjaxRequestTarget target)
            {
                download.initiate(target, fileName);
            }
progress.add(download)
add(progress)

My only problem now is I have to guess the progress of file genaration , to
be dispalyed on the progress bar

thank you very much




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451p4662463.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: DownloadLink and ProgressBar

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Do you want me to build a little example for this?


On Sat, Nov 16, 2013 at 7:59 PM, seyaw <se...@gmail.com> wrote:

> Thank you Ernesto for your prompt response.
> 1. is okay.
> Then for 2. I suppose I start the thread from the onclick method of the
> ajax
> link. Can you explain a bit how to start the file genaration with a thread?
> and for 3. how to pol the server for the progress?
>
> Thank you very much
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451p4662460.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Re: DownloadLink and ProgressBar

Posted by seyaw <se...@gmail.com>.
Thank you Ernesto for your prompt response.
1. is okay. 
Then for 2. I suppose I start the thread from the onclick method of the ajax
link. Can you explain a bit how to start the file genaration with a thread?
and for 3. how to pol the server for the progress?

Thank you very much



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451p4662460.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: DownloadLink and ProgressBar

Posted by Martin Grigorov <mg...@apache.org>.
I didn't read the question correctly.
It indeed talks about showing progress for the generation process, not the
download.


On Mon, Nov 18, 2013 at 10:39 AM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Martin,
>
> Thanks for your comments.
>
> On Mon, Nov 18, 2013 at 9:10 AM, Martin Grigorov <mgrigorov@apache.org
> >wrote:
>
> > Hi,
> >
> > I haven't seen a web application that shows progress bar for download.
> > The browser itself shows such information - Google Chrome in the
> > bottom-left corner, Firefox in its download window/manager.
> >
>
> I'm not talking of a progress bar for download. I'm talking of showing a
> progress bar for file generation (a file that takes too long to generate).
> Once file is generated download will be triggered.  I have implemented a
> similar use case several times before.
>
>
> > > 1-Replace the download link by an AJAX link.
> > > 2-Launch file generation on a background thread. Pass a class to this
> > > thread that serves as context fro passing information from generating
> > > thread with web threads (keeping a reference to thisi context on the
> > page).
> > > 3-Make a progress panel visible + an AJAX timer that pols the server
> for
> > > progress.
> > >
> >
> > Point 3) won't work if the file download is from a resource linked to the
> > page. And it is thru DownloadLink.
> > In this case the ajax timer won't be able to reach the page at all.
> >
>
> ? Not following you. Page and thread generating the file will share a
> context the file generating thread will use to update WEB threads about
> status of generation (e.g. progress info). All the AJAX timer will do is
> poll the page and ask for this information. Once file is generated timer
> will disable itself and trigger download (or display a new panel with
> download link). Again I have implemented something similar more than once
> in my life.
>
>
> >
> > The app should use a mounted/shared resource.
> > see wicket-extensions' UploadProgressBar and/or follow the progress of
> > https://github.com/l0rdn1kk0n/wicket-bootstrap/issues/262 for example.
> > Both
> > are related to *upload*, not download.
> >
>
> Yes I know the limitation of serving resources from pages. Maybe one
> variation of this is that the timer just points to the mounted resource in
> order to trigger the actual download. That is not more difficult to achieve
> that downloading from page.
>
> Shall I build a small mini app illustrating this? Maybe it can be useful to
> other users?
>
> --
> Regards - Ernesto Reinaldo Barreiro
>

RE: DownloadLink and ProgressBar

Posted by Paul Bors <pa...@bors.ws>.
I would be wrong to show a 0% - 100% status bar.

You might want to switch back to an indeterminate progress bar and do what
Apple does during OS X install, show a label letting the user of your
estimate such as "Approximately 5 minutes remaining" or "Less than a minute
remaning".

~ Thank you,
  Paul Bors

-----Original Message-----
From: seyaw [mailto:seidymam@gmail.com] 
Sent: Monday, November 18, 2013 2:25 PM
To: users@wicket.apache.org
Subject: RE: DownloadLink and ProgressBar

Yes Paul, getting the progress of the file generation is one of my challenge
right now. The file generation is, in my case is not linear. For example,
the time it takes for different procedures is depend on the project size.
Currently, I just make a rough estimation so that the user at least can see
the file generation is in progress. 



--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp46
62451p4662504.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
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: DownloadLink and ProgressBar

Posted by seyaw <se...@gmail.com>.
Yes Paul, getting the progress of the file generation is one of my challenge
right now. The file generation is, in my case is not linear. For example,
the time it takes for different procedures is depend on the project size.
Currently, I just make a rough estimation so that the user at least can see
the file generation is in progress. 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451p4662504.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: DownloadLink and ProgressBar

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
What do you mean? How to compute how much has been generated? Or how to
pass this info to the client? Or something else?


On Mon, Nov 18, 2013 at 8:00 PM, Paul Bors <pa...@bors.ws> wrote:

> How do you track the progress of your file generation in order to show the
> status bar?
>
> ~ Thank you,
>   Paul Bors
>
> -----Original Message-----
> From: seyaw [mailto:seidymam@gmail.com]
> Sent: Monday, November 18, 2013 3:52 AM
> To: users@wicket.apache.org
> Subject: Re: DownloadLink and ProgressBar
>
> Hi Ernesto,
> A working example might be helpful.
> Thank you
>
>
>
> --
> View this message in context:
>
> http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp46
> 62451p4662485.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

RE: DownloadLink and ProgressBar

Posted by Paul Bors <pa...@bors.ws>.
How do you track the progress of your file generation in order to show the
status bar?

~ Thank you,
  Paul Bors

-----Original Message-----
From: seyaw [mailto:seidymam@gmail.com] 
Sent: Monday, November 18, 2013 3:52 AM
To: users@wicket.apache.org
Subject: Re: DownloadLink and ProgressBar

Hi Ernesto,
A working example might be helpful.
Thank you



--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp46
62451p4662485.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
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: DownloadLink and ProgressBar

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Thanks for the pointer!


On Mon, Nov 18, 2013 at 10:54 AM, Martin Grigorov <mg...@apache.org>wrote:

> I think
>
> https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/progressbar-parent
> has
> such examples
>
>
> On Mon, Nov 18, 2013 at 10:52 AM, seyaw <se...@gmail.com> wrote:
>
> > Hi Ernesto,
> > A working example might be helpful.
> > Thank you
> >
> >
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451p4662485.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>



-- 
Regards - Ernesto Reinaldo Barreiro

Re: DownloadLink and ProgressBar

Posted by Martin Grigorov <mg...@apache.org>.
I think
https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/progressbar-parent
has
such examples


On Mon, Nov 18, 2013 at 10:52 AM, seyaw <se...@gmail.com> wrote:

> Hi Ernesto,
> A working example might be helpful.
> Thank you
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451p4662485.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: DownloadLink and ProgressBar

Posted by seyaw <se...@gmail.com>.
Hi Ernesto,
A working example might be helpful.
Thank you



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451p4662485.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: DownloadLink and ProgressBar

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Martin,

Thanks for your comments.

On Mon, Nov 18, 2013 at 9:10 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
> I haven't seen a web application that shows progress bar for download.
> The browser itself shows such information - Google Chrome in the
> bottom-left corner, Firefox in its download window/manager.
>

I'm not talking of a progress bar for download. I'm talking of showing a
progress bar for file generation (a file that takes too long to generate).
Once file is generated download will be triggered.  I have implemented a
similar use case several times before.


> > 1-Replace the download link by an AJAX link.
> > 2-Launch file generation on a background thread. Pass a class to this
> > thread that serves as context fro passing information from generating
> > thread with web threads (keeping a reference to thisi context on the
> page).
> > 3-Make a progress panel visible + an AJAX timer that pols the server for
> > progress.
> >
>
> Point 3) won't work if the file download is from a resource linked to the
> page. And it is thru DownloadLink.
> In this case the ajax timer won't be able to reach the page at all.
>

? Not following you. Page and thread generating the file will share a
context the file generating thread will use to update WEB threads about
status of generation (e.g. progress info). All the AJAX timer will do is
poll the page and ask for this information. Once file is generated timer
will disable itself and trigger download (or display a new panel with
download link). Again I have implemented something similar more than once
in my life.


>
> The app should use a mounted/shared resource.
> see wicket-extensions' UploadProgressBar and/or follow the progress of
> https://github.com/l0rdn1kk0n/wicket-bootstrap/issues/262 for example.
> Both
> are related to *upload*, not download.
>

Yes I know the limitation of serving resources from pages. Maybe one
variation of this is that the timer just points to the mounted resource in
order to trigger the actual download. That is not more difficult to achieve
that downloading from page.

Shall I build a small mini app illustrating this? Maybe it can be useful to
other users?

-- 
Regards - Ernesto Reinaldo Barreiro

Re: DownloadLink and ProgressBar

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

I haven't seen a web application that shows progress bar for download.
The browser itself shows such information - Google Chrome in the
bottom-left corner, Firefox in its download window/manager.


On Sat, Nov 16, 2013 at 11:40 AM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Hi,
>
>
> 1-Replace the download link by an AJAX link.
> 2-Launch file generation on a background thread. Pass a class to this
> thread that serves as context fro passing information from generating
> thread with web threads (keeping a reference to thisi context on the page).
> 3-Make a progress panel visible + an AJAX timer that pols the server for
> progress.
>

Point 3) won't work if the file download is from a resource linked to the
page. And it is thru DownloadLink.
In this case the ajax timer won't be able to reach the page at all.

The app should use a mounted/shared resource.
see wicket-extensions' UploadProgressBar and/or follow the progress of
https://github.com/l0rdn1kk0n/wicket-bootstrap/issues/262 for example. Both
are related to *upload*, not download.


> 4-Once file is generated replace progress panel with a download link (or
> use trick in [1] to trigger file dowmload)
>
> References
>
> 1-
>
> https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow
>
>
> On Sat, Nov 16, 2013 at 10:29 AM, seyaw <se...@gmail.com> wrote:
>
> > Hi All,
> > I have a wicket DownloadLink where I generate file dynamically and
> download
> > it. It works.
> > The process of dynamic File generation might take some time and like to
> > show
> > ProgressBar which show how much the generation has progressed. How Can I
> do
> > that.
> >
> > I am using wicket 1.5.8
> > Thank you very much.
> >
> >  add(new DownloadLink("export", new LoadableDetachableModel<File>()
> >         {
> >             private static final long serialVersionUID =
> > 840863954694163375L;
> >
> >             @Override
> >             protected File load()
> >             {
> >                 File exportTempDir = getGeneratedFile();
> > }
> > }
> >
> >
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>

Re: DownloadLink and ProgressBar

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,


1-Replace the download link by an AJAX link.
2-Launch file generation on a background thread. Pass a class to this
thread that serves as context fro passing information from generating
thread with web threads (keeping a reference to thisi context on the page).
3-Make a progress panel visible + an AJAX timer that pols the server for
progress.
4-Once file is generated replace progress panel with a download link (or
use trick in [1] to trigger file dowmload)

References

1-
https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow


On Sat, Nov 16, 2013 at 10:29 AM, seyaw <se...@gmail.com> wrote:

> Hi All,
> I have a wicket DownloadLink where I generate file dynamically and download
> it. It works.
> The process of dynamic File generation might take some time and like to
> show
> ProgressBar which show how much the generation has progressed. How Can I do
> that.
>
> I am using wicket 1.5.8
> Thank you very much.
>
>  add(new DownloadLink("export", new LoadableDetachableModel<File>()
>         {
>             private static final long serialVersionUID =
> 840863954694163375L;
>
>             @Override
>             protected File load()
>             {
>                 File exportTempDir = getGeneratedFile();
> }
> }
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/DownloadLink-and-ProgressBar-tp4662451.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro