Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to provide a download button?
How to provide a download button? [message #946851] Tue, 16 October 2012 15:08 Go to next message
Christian Schwarz is currently offline Christian Schwarz
Messages: 31
Registered: July 2009
Member
Hi RAP Fans,

I found this link were it is described how to provide a download link. My Download-ServiceHandler is working nice but now i want to provide a button. How can I trigger a download in the current browser-tab without falling back to ExternalBrowser.open(..) (it forces the user to close that beast)?

Thanks Chris
Re: How to provide a download button? [message #946869 is a reply to message #946851] Tue, 16 October 2012 15:22 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1846
Registered: July 2009
Senior Member
Hi Christian,
with the markup support for Label you could put an <a> tag into a label
text that points to your download file or download service handler.
HTH,
Ivan

On 10/16/2012 6:08 PM, Christian Schwarz wrote:
> Hi RAP Fans,
>
> I found
> http://wiki.eclipse.org/RAP/FAQ#How_to_provide_a_download_link.3F link
> were it is described how to provide a download link. My
> Download-ServiceHandler is working nice but now i want to provide a
> button. How can I trigger a download in the current browser-tab
> without falling back to ExternalBrowser.open(..) (it forces the user
> to close that beast)?
>
> Thanks Chris

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to provide a download button? [message #947008 is a reply to message #946869] Tue, 16 October 2012 18:26 Go to previous messageGo to next message
Christian Schwarz is currently offline Christian Schwarz
Messages: 31
Registered: July 2009
Member
Ivan Furnadjiev wrote on Tue, 16 October 2012 11:22
Hi Christian,
with the markup support for Label you could put an <a> tag into a label
text that points to your download file or download service handler.


Hi Evan,

thanks for your reply, I know the Label soulution from the FAQ but i need a Button. I figured out that it is possible to open a Browser pointing to the URL of the download service handler. I can hide the Browser by setting its size to zero in width & height, but i don't know when i should dispose the Browser instance. If i dispose it after calling #setUrl(String) noting happes (at least in IE8).
Re: How to provide a download button? [message #947333 is a reply to message #947008] Wed, 17 October 2012 02:23 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris Fairhall
Messages: 101
Registered: February 2011
Senior Member
You could add a little Browser widget on the page somewhere. I haven't tested it in RAP but setting the src of an IFrame to a URL that would normally trigger the browsers download prompt still works when done via Javascript (at least in IE9 and FF16).

Re: How to provide a download button? [message #947519 is a reply to message #947333] Wed, 17 October 2012 06:47 Go to previous messageGo to next message
Christian Schwarz is currently offline Christian Schwarz
Messages: 31
Registered: July 2009
Member
You don't have call Browser#setText(String) with the src of an IFrame, the download is triggerd once Browser#setUrl(String) is called. I guess its the same effect in Browser-Widget because it is redered as IFrame at the client side.
But yes one could place a "hidden" Browser some where in side the application an reuse it to trigger downloads, it feels like a dirty workaround.
Re: How to provide a download button? [message #948918 is a reply to message #947519] Thu, 18 October 2012 14:08 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf Sternberg
Messages: 1291
Registered: July 2009
Senior Member

Hi Christian,

As far as I know, HTML/DOM doesn't provide a method to directly trigger
a download, doing so requires this kind of workaround. However, maybe it
would feel better if it was wrapped in a custom download widget?

Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: How to provide a download button? [message #948957 is a reply to message #948918] Thu, 18 October 2012 14:49 Go to previous message
Cole Markham is currently offline Cole Markham
Messages: 133
Registered: July 2009
Senior Member
Some browsers (notably IE) may block downloads if triggered by JavaScript (which of course RAP uses). So creating a Browser widget to trigger the download from a button may trigger this behavior. When this happens in IE, depending on settings, the "yellow information bar" will pop in from the top prompting the user to approve the download. Unfortunately, this will cause the page to reload losing whatever context you had. Because of these issues, I prefer the solution of using a link. If you want it to look like a button, perhaps you could add custom CSS style.

To answer your question about when to dispose the browser widget, you have to wait until the download is complete. That would be once the DownloadServiceHandler.service() method is complete, so you should setup some sort of listener to notify your view once the service handler finishes. Then you can dispose the Browser widget and unregister the service handler.

Hope that helps,

Cole
Previous Topic:Update View Dynamically?
Next Topic:error occors after move the runtime to rap 2.0 nightly build!
Goto Forum:
  


Current Time: Thu Oct 30 18:34:17 GMT 2014

Powered by FUDForum. Page generated in 0.13416 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software