org.olat.core.gui.components.download
Class DisplayOrDownloadComponent

java.lang.Object
  extended by org.olat.core.gui.components.Component
      extended by org.olat.core.gui.components.download.DisplayOrDownloadComponent

public class DisplayOrDownloadComponent
extends Component

Description:
The DisplayOrDownloadFileComponent offers a way to open a javascript popup window and open a resource in this window. Note that this might be blocked by the browser!

In case the browser can display the content, it will display it in the browser. Otherwhise, it will start downloading the file.

A filedownload is only triggered once. If the component becomes visible a second time, the filedownload will not be initiated again and again. A second filedowload can be triggered by using the triggerFileDownload() method.

Initial Date: 05.11.2009

Author:
gnaegi

Constructor Summary
DisplayOrDownloadComponent(java.lang.String name, java.lang.String fileUrl)
          Constructor.
 
Method Summary
 ComponentRenderer getHTMLRendererSingleton()
           
 void triggerFileDownload(java.lang.String fileUrl)
          Set the file URL of the file that should be downloaded automatically.
 
Methods inherited from class org.olat.core.gui.components.Component
addListener, debuginfoGetListeners, dispatchRequest, getAndClearLatestFiredEvent, getComponentName, getDispatchID, getExtendedDebugInfo, getLatestDispatchedController, getListenerInfo, getParent, getSpanAsDomReplaceable, getTimestamp, getTranslator, isDirty, isDirtyForUser, isDomReplaceable, isEnabled, isVisible, setDirty, setDomReplaceable, setEnabled, setSpanAsDomReplaceable, setVisible, toString, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DisplayOrDownloadComponent

public DisplayOrDownloadComponent(java.lang.String name,
                                  java.lang.String fileUrl)
Constructor. Use the triggerFileDownload() method to set the file URL later to another URL

Parameters:
name - the component name
fileUrl - a valid URL that points to a file to be downloaded. Note that this controller does only open the URL in a new window which triggers the download or display of the file. The dispatching of the file is up to the caller of this method. NULL if not known at the moment. Use triggerFileDownload() in such cases later on.
Method Detail

getHTMLRendererSingleton

public ComponentRenderer getHTMLRendererSingleton()
Specified by:
getHTMLRendererSingleton in class Component
See Also:
Component.getHTMLRendererSingleton()

triggerFileDownload

public void triggerFileDownload(java.lang.String fileUrl)
Set the file URL of the file that should be downloaded automatically. This method can optionally be used to the constructor when a) the fileURL is not yet known at construction time or b) you want to use this controller repeatedly to download different files.

Parameters:
fileUrl - a valid URL that points to a file to be downloaded. Note that this controller does only open the URL in a new window which triggers the download or display of the file. The dispatching of the file is up to the caller of this method.