|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.server.AbstractClientConnector
com.vaadin.server.AbstractExtension
com.vaadin.server.FileDownloader
public class FileDownloader
Extension that starts a download when the extended component is clicked. This is used to overcome two challenges:
Please note that the download will be started in an iframe, which means that
care should be taken to avoid serving content types that might make the
browser attempt to show the content using a plugin instead of downloading it.
Connector resources (e.g. FileResource and ClassResource)
will automatically be served using a
Content-Type: application/octet-stream header unless
setOverrideContentType(boolean) has been set to false
while files served in other ways, (e.g. ExternalResource or
ThemeResource) will not automatically get this treatment.
| Constructor Summary | |
|---|---|
FileDownloader(Resource resource)
Creates a new file downloader for the given resource. |
|
| Method Summary | |
|---|---|
void |
extend(AbstractComponent target)
|
Resource |
getFileDownloadResource()
Gets the resource set for download. |
boolean |
handleConnectorRequest(VaadinRequest request,
VaadinResponse response,
java.lang.String path)
Handle a request directed to this connector. |
boolean |
isOverrideContentType()
Checks whether the content type should be overridden. |
void |
setOverrideContentType(boolean overrideContentType)
Sets whether the content type of served resources should be overriden to application/octet-stream to reduce the risk of a browser
plugin choosing to display the resource instead of downloading it. |
| Methods inherited from class com.vaadin.server.AbstractExtension |
|---|
extend, getSupportedParentType, removeFromTarget, setParent |
| Methods inherited from class com.vaadin.server.AbstractClientConnector |
|---|
addExtension, addMethodInvocationToQueue, attach, beforeClientResponse, createState, detach, encodeState, getAllChildrenIterable, getConnectorId, getExtensions, getParent, getResource, getRpcManager, getRpcProxy, getSession, getState, getStateType, getUI, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setResource |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.vaadin.server.ClientConnector |
|---|
attach, beforeClientResponse, detach, encodeState, getExtensions, getParent, getStateType, getUI, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls |
| Methods inherited from interface com.vaadin.shared.Connector |
|---|
getConnectorId |
| Methods inherited from interface com.vaadin.server.RpcTarget |
|---|
getRpcManager |
| Constructor Detail |
|---|
public FileDownloader(Resource resource)
AbstractExtension.extend(AbstractClientConnector) the
component.
resource - the resource to download when the user clicks the extended
component.| Method Detail |
|---|
public void extend(AbstractComponent target)
public Resource getFileDownloadResource()
public void setOverrideContentType(boolean overrideContentType)
application/octet-stream to reduce the risk of a browser
plugin choosing to display the resource instead of downloading it. This
is by default set to true.
Please note that this only affects Connector resources (e.g.
FileResource and ClassResource) but not other resource
types (e.g. ExternalResource or ThemeResource).
overrideContentType - true to override the content type if possible;
false to use the original content type.public boolean isOverrideContentType()
true if the content type will be overridden when
possible; false if the original content type will be
used.setOverrideContentType(boolean)
public boolean handleConnectorRequest(VaadinRequest request,
VaadinResponse response,
java.lang.String path)
throws java.io.IOException
ClientConnectorConnectorResources.
Requests to /APP/connector/[ui id]/[connector id]/ are
routed to this method with the remaining part of the requested path
available in the path parameter.
DynamicConnectorResource can be used to easily make an
appropriate URL available to the client-side code.
handleConnectorRequest in interface ClientConnectorhandleConnectorRequest in class AbstractClientConnectorrequest - the request that should be handledresponse - the response object to which the response should be writtenpath - the requested relative path
true if the request has been handled,
false if no response has been written.
java.io.IOException - if there is a problem generating a response.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||