Packagecom.yworks.remote
Classpublic class DownloadHandler
InheritanceDownloadHandler Inheritance flash.events.EventDispatcher

Handler for server requests that are expected to respond with a file stream which will be saved locally.



Public Properties
 PropertyDefined by
  additionalParameters : Object
Get or set an object containing additional parameters that will be transfered to the service URL.
DownloadHandler
  compress : Boolean
Whether to use compression for the graphml data that is sent to the server.
DownloadHandler
  outputIOHandler : GraphMLIOHandler
Get or set the GraphMLIOHandler instance that will be used for graph serialization.
DownloadHandler
  uriEncode : Boolean
Whether to encode the graphML string sent to the server using the global encodeURIComponent function.
DownloadHandler
Public Methods
 MethodDefined by
  
DownloadHandler(downloadURL:String, roundtripHandler:RoundtripHandler = null)
Create a new instance for the given service URL.
DownloadHandler
  
download(graph:IGraph, defaultFileName:String):void
Calls the download URL that was passed upon initialization.
DownloadHandler
Protected Methods
 MethodDefined by
  
Create the GraphMLIOHandler instance that will be used for graph serialization.
DownloadHandler
  
createURLRequest(downloadURL:String):URLRequest
Create the URLRequest instance that will be used for the download request.
DownloadHandler
  
createURLVariables(graph:IGraph):URLVariables
Create the parameters object that is transferred to the server.
DownloadHandler
  
onComplete(evt:Event):void
Called when the download operation has finished succesfully.
DownloadHandler
  
onHTTPStatus(evt:HTTPStatusEvent):void
Called when the server sends a HTTP status.
DownloadHandler
  
onIOError(evt:IOErrorEvent):void
Called when an IO error occurs while executing the file download.
DownloadHandler
  
onSecurityError(evt:SecurityErrorEvent):void
Called when a security error occurs while executing the file download.
DownloadHandler
  
onSelect(evt:Event):void
Called when the user has selected a location for the file download.
DownloadHandler
Property detail
additionalParametersproperty
additionalParameters:Object  [read-write]

Get or set an object containing additional parameters that will be transfered to the service URL.

Implementation
    public function get additionalParameters():Object
    public function set additionalParameters(value:Object):void
compressproperty 
compress:Boolean  [read-write]

Whether to use compression for the graphml data that is sent to the server.

If true, the value of the "graph" parameter will be compressed using zlib compression and encoded using base64 encoding.

The default value is true.

Implementation
    public function get compress():Boolean
    public function set compress(value:Boolean):void
outputIOHandlerproperty 
outputIOHandler:GraphMLIOHandler  [read-write]

Get or set the GraphMLIOHandler instance that will be used for graph serialization.

Implementation
    public function get outputIOHandler():GraphMLIOHandler
    public function set outputIOHandler(value:GraphMLIOHandler):void

See also

uriEncodeproperty 
uriEncode:Boolean  [read-write]

Whether to encode the graphML string sent to the server using the global encodeURIComponent function.

The default value is false.

Implementation
    public function get uriEncode():Boolean
    public function set uriEncode(value:Boolean):void

See also

Constructor detail
DownloadHandler()constructor
public function DownloadHandler(downloadURL:String, roundtripHandler:RoundtripHandler = null)

Create a new instance for the given service URL.

Parameters
downloadURL:String — An URL that corresponds to a service which sends a file to the client.
 
roundtripHandler:RoundtripHandler (default = null) — The roundtrip handler to receive the outputIOHandler from.
Method detail
createOutputIOHandler()method
protected function createOutputIOHandler():GraphMLIOHandler

Create the GraphMLIOHandler instance that will be used for graph serialization. This implementation uses the RoundtripHandler that has been passed to the constructor and returns its output io handler.

Returns
GraphMLIOHandler — the GraphMLIOHandler instance created.

See also

createURLRequest()method 
protected function createURLRequest(downloadURL:String):URLRequest

Create the URLRequest instance that will be used for the download request.

Parameters
downloadURL:String — The service URL that was passed upon initialization.

Returns
URLRequest — An URLRequest instance that will be used in the download method.
createURLVariables()method 
protected function createURLVariables(graph:IGraph):URLVariables

Create the parameters object that is transferred to the server.

This implementation will include a serialization of the current graph instance contained in the graphCanvas, if send is true. The GraphML string will be sent as a request parameter named "graph".

If compress is true, the GraphML serialization of the graph will be compressed and base64-encoded. This is indicated to the server by prepending "base64/zlib" to the "graphEncoding" request parameter.
If uriEncode is true, the GraphML string will be encoded using the global encodeURIComponent function. This is indicated to the server by setting thge "graphEncoding" request parameter to "encodeURIComponent".

Parameters
graph:IGraph — The graph to be serialized

Returns
URLVariables — The parameters object to be transferred to the server.

See also

download()method 
public function download(graph:IGraph, defaultFileName:String):void

Calls the download URL that was passed upon initialization.

Event handling can be customized by overriding the various protected event handler functions.

Parameters
graph:IGraph — The graph instance that is to be serialized.
 
defaultFileName:String — The default file name to be shown in the browser's download dialog.
onComplete()method 
protected function onComplete(evt:Event):void

Called when the download operation has finished succesfully.

This implementation removes the busy cursor.

Parameters
evt:Event
onHTTPStatus()method 
protected function onHTTPStatus(evt:HTTPStatusEvent):void

Called when the server sends a HTTP status.

This implementation is empty.

Parameters
evt:HTTPStatusEvent
onIOError()method 
protected function onIOError(evt:IOErrorEvent):void

Called when an IO error occurs while executing the file download.

This implementation shows an alert message, traces the event and removes the busy cursor.

Parameters
evt:IOErrorEvent
onSecurityError()method 
protected function onSecurityError(evt:SecurityErrorEvent):void

Called when a security error occurs while executing the file download.

This implementation shows an alert message, traces the event and removes the busy cursor.

Parameters
evt:SecurityErrorEvent
onSelect()method 
protected function onSelect(evt:Event):void

Called when the user has selected a location for the file download.

This implementation sets the busy cursor.

Parameters
evt:Event