Skip to main content



      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 11:08 Go to next message
Eclipse UserFriend
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 11:22 Go to previous messageGo to next message
Eclipse UserFriend
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 14:26 Go to previous messageGo to next message
Eclipse UserFriend
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] Tue, 16 October 2012 22:23 Go to previous messageGo to next message
Eclipse UserFriend
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 02:47 Go to previous messageGo to next message
Eclipse UserFriend
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 10:08 Go to previous messageGo to next message
Eclipse UserFriend
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 10:49 Go to previous message
Eclipse UserFriend
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:Accessing default presentations while using a PresentationFactory
Next Topic:Browser won't show in RAP 1.4.2
Goto Forum:
  


Current Time: Wed Jul 23 14:26:42 EDT 2025

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

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

Back to the top