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
  fileName : String
[read-only] The name of the last sucessfuly downloaded file.
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
  
onCancel(evt:Event):void
Called when the user cancels the download using the file chooser's cancel button.
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
  
onProgress(evt:ProgressEvent):void
Dispatched periodically during the file upload or download operation.
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

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

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
fileNameproperty 
fileName:String  [read-only]

The name of the last sucessfuly downloaded file.


Implementation
    public function get fileName():String
outputIOHandlerproperty 
outputIOHandler:GraphMLIOHandler

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

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.

onCancel()method 
protected function onCancel(evt:Event):void

Called when the user cancels the download using the file chooser's cancel button.

Flash Player does not dispatch this event if the user cancels an upload or download through other means (closing the browser or stopping the current application).

This implementation does nothing.

Parameters

evt:Event

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

onProgress()method 
protected function onProgress(evt:ProgressEvent):void

Dispatched periodically during the file upload or download operation.

The progress event is dispatched while Flash Player transmits bytes to a server, and it is periodically dispatched during the transmission, even if the transmission is ultimately not successful. To determine if and when the file transmission is actually successful and complete, listen for the complete event.

In some cases, progress events are not received. For example, when the file being transmitted is very small or the upload or download happens very quickly a progress event might not be dispatched.

This implementation does nothing.

Parameters

evt:ProgressEvent

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