Packagecom.yworks.remote
Classpublic class UploadHandler
InheritanceUploadHandler Inheritance flash.events.EventDispatcher

A Handler which sends a file to a server and expects a GraphML encoded graph as reponse.

This implementation delegates the work to a flash.net.FileReference.

The server will recieve a multipart/form-data encoded request of the form:

	 Content-Type: multipart/form-data; boundary=AaB03x
	 --AaB03x
	 Content-Disposition: form-data; name="graph"; filename="example.graphml"
	 Content-Type: application/octet-stream
	  ... contents of example.graphml ...
	 --AaB03x-- 
	 

To handle this request, the yFiles FLEX server API offers convenicene classes which send the file's contents back in the response.

See also

flash.net.FileReference


Public Properties
 PropertyDefined By
  additionalParameters : Object
Get or set an object containing additional parameters that will be transfered to the service URL.
UploadHandler
  fileFilter : Array
An array of flash.net.FileFilter to use with the file browser.
UploadHandler
  filename : String
[read-only] The filename of the last selected file.
UploadHandler
  inputIOHandler : GraphMLIOHandler
The GraphMLIOHandler instance that will be used for graph deserialization.
UploadHandler
  roundtripHandler : RoundtripHandler
The RoundtripHandler instance that will be used for the server roundtrip.
UploadHandler
Public Methods
 MethodDefined By
  
UploadHandler(uploadURL:String, roundtripHandler:RoundtripHandler = null)
Create a new instance for the given service URL.
UploadHandler
  
upload(graph:IGraph = null, defaultFileName:String = null):void
Calls the upload URL that was passed upon initialization.
UploadHandler
Protected Methods
 MethodDefined By
  
Create the GraphMLIOHandler instance that will be used for graph deserialization.
UploadHandler
  
createURLRequest(uploadURL:String):URLRequest
Create the URLRequest instance that will be used for the upload request.
UploadHandler
  
createURLVariables():URLVariables
Create the parameters object that is transferred to the server.
UploadHandler
  
dispatchXMLResult(result:XML):void
Dispatches a XMLResultEvent containing the received XML data.
UploadHandler
  
onCancel(event:Event):void
Called when the user chose the cancel button of the upload dialog.
UploadHandler
  
onComplete(event:Event):void
Called when the data is completely sent to the server.
UploadHandler
  
onHTTPStatus(evt:HTTPStatusEvent):void
Called when the server sends a HTTP status.
UploadHandler
  
onIOError(evt:IOErrorEvent):void
Called when an IO error occurs while executing the file download.
UploadHandler
  
onSecurityError(evt:SecurityErrorEvent):void
Called when a security error occurs while executing the file download.
UploadHandler
  
onSelected(event:Event):void
Called when a file is chosen for upload from the FileChooser.
UploadHandler
  
onUploadComplete(event:DataEvent):void
Called after the upload is complete and the response is recieved.
UploadHandler
Events
 Event Summary Defined By
  Dispatched when the upload method was called and a valid result is received.UploadHandler
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
fileFilterproperty 
fileFilter:Array

An array of flash.net.FileFilter to use with the file browser.

Implement a custom set of FileFilter like:

		 fileFilter = new Array(
		         new FileFilter("GraphML files (graphml)", "graphml"),
		         new FileFilter("all files (", ")
		                        );
		 

The default value is new Array( new FileFilter("GraphML files (graphml)", "graphml"), new FileFilter("all files (", ") );.


Implementation
    public function get fileFilter():Array
    public function set fileFilter(value:Array):void
filenameproperty 
filename:String  [read-only]

The filename of the last selected file.


Implementation
    public function get filename():String
inputIOHandlerproperty 
inputIOHandler:GraphMLIOHandler

The GraphMLIOHandler instance that will be used for graph deserialization.

By default, the IO handler is created by createInputIOHandler.

If the upload method is called without a graph parameter, this property will be ignored and the roundtripHandler will be used instead.


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

See also

roundtripHandlerproperty 
roundtripHandler:RoundtripHandler

The RoundtripHandler instance that will be used for the server roundtrip.

If no IO handler is set to the inputIOHandler property, this RoundtripHandler instance will be used to create one.

If the upload method is used without the graph parameter, a fully configured RoundtripHandler has to be passed to this instance, either by setting this property or by passing it to the constructor's roundtripHandler parameter.


Implementation
    public function get roundtripHandler():RoundtripHandler
    public function set roundtripHandler(value:RoundtripHandler):void
Constructor Detail
UploadHandler()Constructor
public function UploadHandler(uploadURL:String, roundtripHandler:RoundtripHandler = null)

Create a new instance for the given service URL.

Parameters
uploadURL:String — An URL that corresponds to a service which recieves a file from the client.
 
roundtripHandler:RoundtripHandler (default = null) — The roundtrip handler to receive the inputIOHandler from.
Method Detail
createInputIOHandler()method
protected function createInputIOHandler():GraphMLIOHandler

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

Returns
GraphMLIOHandler — the GraphMLIOHandler instance created.

See also

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

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

Parameters

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

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

Create the parameters object that is transferred to the server.

Returns
URLVariables
dispatchXMLResult()method 
protected function dispatchXMLResult(result:XML):void

Dispatches a XMLResultEvent containing the received XML data.

Parameters

result:XML

See also

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

Called when the user chose the cancel button of the upload dialog.

Parameters

event:Event

onComplete()method 
protected function onComplete(event:Event):void

Called when the data is completely sent to the server.

Parameters

event: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

onSelected()method 
protected function onSelected(event:Event):void

Called when a file is chosen for upload from the FileChooser.

Creates the URLRequest and start the upload process.

Parameters

event:Event

onUploadComplete()method 
protected function onUploadComplete(event:DataEvent):void

Called after the upload is complete and the response is recieved.

If a graph parameter was passed to the upload() method, the result will be written to that graph using the inputIOHandler. Otherwise, the roundtripHandler will be used.

This method will call dispatchXMLResult to dispatch a XMLResultEvent containing the received XML data.

Parameters

event:DataEvent — A DataEvent which holds the GraphML data in its text property.

upload()method 
public function upload(graph:IGraph = null, defaultFileName:String = null):void

Calls the upload URL that was passed upon initialization.

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

Parameters

graph:IGraph (default = null) — The graph instance in which the file contents will be stored. If no graph is passed, the roundtripHandler will be used to store the graph to. Note, that in this case, the roundtripHandler has to be properly initialized.
 
defaultFileName:String (default = null) — The default file name to be shown in the browser's download dialog.

See also

flash.net.FileReference
flash.net.FileFilter
Event Detail
complete Event
Event Object Type: com.yworks.remote.XMLResultEvent
XMLResultEvent.type property = com.yworks.remote.XMLResultEvent.COMPLETE

Dispatched when the upload method was called and a valid result is received.

The event is dispatched before doUpdate is called.

Dispatched after a valid XML was recieved from the server. The recieved XML is stored in the xmlResult property.