Packagecom.yworks.remote
Classpublic class RoundtripHandler
InheritanceRoundtripHandler Inheritance AbstractRoundtripHandler Inheritance flash.events.EventDispatcher
Implements ResultHandler, mx.core.IMXMLObject

The central result handler that should be used for client-server round-tripping.

Usually, if the server doesn't keep any state, this result handler will be used for sending the graph currently displayed on the client to the server. The server can then somehow modify the structure, layout or style of the graph and send the changed state back to the client.

Whether this handler conducts communication in both directions or whether the graph state is just sent or received can be configured using the send and update flags.

The GraphML (de)serialization of the current graph instance can be controlled using the various methods that configure the GraphMLIOHandlers used for parsing and writing GraphML data.

When you call the run() method, a HTTP request is sent to the specified URL and a HTTP response is returned. If send is set to true the graphCanvass graph is sent to the server. When the response is returned, handleResult is called. If update is set to true, the returned GraphML will be parsed into a temporary graph whose contents will be transferred to the visible graph.

handleResult will dispatch the following RoundtripEvents to provide handles for the different stages of the update process:

Instances of this class can be created in Actionscript as well as in MXML: Actionscript:

     var roundtrip:RoundtripHandler = new RoundtripHandler(graphCanvas, "service");
     

MXML SyntaxexpandedHide MXML Syntax
<yworks:RoundtripHandler id="roundTrip" graphCanvas="{graphCanvas}" serviceName="service"> <yworks:additionalParameters> <mx:Object paramName="paramValue"/> </yworks:additionalParameters> </yworks:RoundtripHandler> The above configuration will send an additional parameter "paramName" with the value "paramValue" when the run() method is called.


Public Properties
 PropertyDefined By
 InheritedadditionalParameters : Object
Get or set an Object containing additional request parameters that should be send to the server.
AbstractRoundtripHandler
  adjustFontSize : Boolean
[override]
RoundtripHandler
  animate : Boolean
Get or set whether the optional update of the current graph instance should be animated.
RoundtripHandler
 InheritedautoReadMapperData : Boolean
Whether mapper data contained in the GraphML data should be automatically deserialized and registered with the graph's mapper registry.
AbstractRoundtripHandler
 InheritedautoWriteMapperData : Boolean
Whether mapper data registered with the graph's mapper registry should be automatically serialized.
AbstractRoundtripHandler
  clearLocalGraph : Boolean
Get or set whether the graph in the canvas should be cleared before the update.
RoundtripHandler
 Inheritedcompress : Boolean
Whether to use compression for the graphml data that is sent to the server.
AbstractRoundtripHandler
  customErrorHandler : Function
A local custom error handler that will be used by this instance instead of the globalCustomErrorHandler.
RoundtripHandler
  faultEventHandler : Function
A local fault event handler that will be used by this instance instead of the globalFaultEventHandler.
RoundtripHandler
  fitContentOnUpdate : Boolean
Gets or sets whether the canvas should fit the contents after the update if animation is disabled.
RoundtripHandler
  globalCustomErrorHandler : Function
[static] The static custom error handler that is used by all RoundtripHandlers, if no customErrorHandler is registered.
RoundtripHandler
  globalFaultEventHandler : Function
[static] The static fault event delegate that is used by all RoundtripHandlers, if no faultEventHandler is registered.
RoundtripHandler
  graphCanvas : GraphCanvasComponent
The graph canvas component that was passed for initialization of this instance.
RoundtripHandler
  inputIOHandler : GraphMLIOHandler
Get or set the GraphMLIOhandler instance that will be used for GraphML input if update is set.
RoundtripHandler
 InheritedlocalViewMode : Boolean
Whether to read/write only the local view for folded graphs.
AbstractRoundtripHandler
 InheritedmapperAttributes : Array
An array of MapperAttribute instances.
AbstractRoundtripHandler
  outputIOHandler : GraphMLIOHandler
Get or set the GraphMLIOHandler instance that will be used for GraphML output if send is set.
RoundtripHandler
 InheritedreadPortLayout : Boolean
Whether to update the port location on reading using the port layout data.
AbstractRoundtripHandler
  requestTimeout : int
The timeout in seconds for sent roundtrips.
RoundtripHandler
  send : Boolean
Gets or sets whether the graph currently displayed in the graph canvas should be sent to the server.
RoundtripHandler
 InheritedsendLocalRoot : Boolean
If the graph that is send is a IFoldedGraph, this property determines whether the id of the node that is set as the folded graph's localRoot is sent as a request parameter to the server.
AbstractRoundtripHandler
  sendOptions : uint
Gets or sets the options to use for sending the graph to the server.
RoundtripHandler
  serviceName : String
[override]
RoundtripHandler
  update : Boolean
Gets or sets whether the graph instance currently displayed in the graph canvas should be updated using the GraphML data sent by the server.
RoundtripHandler
  updateOptions : uint
Get or set the options to use for the graph update.
RoundtripHandler
 InheriteduriEncode : Boolean
Whether to encode the graphML string sent to the server using the global encodeURIComponent function.
AbstractRoundtripHandler
 InheriteduseJavaStyles : Boolean
Whether to use style implementations that were created for compatibility with the yFiles Java realizers.
AbstractRoundtripHandler
Protected Properties
 PropertyDefined By
 Inherited_sendOptions : uint = 0xFFFFFFFF
The options to use for configuration of the output IO handler.
AbstractRoundtripHandler
 Inherited_updateOptions : uint = 0xFFFFFFFF
The options to use for configuration of the input IO handler.
AbstractRoundtripHandler
Public Methods
 MethodDefined By
  
RoundtripHandler(graphCanvas:GraphCanvasComponent = null, serviceName:String = roundtrip, options:uint = 0xFFFFFFFF)
Creates a new instance of the round trip handler for the given component.
RoundtripHandler
  
addDeserializer(deserializer:IDeserializer):void
[override]
RoundtripHandler
  
addMapperAttribute(tag:Object, name:String = null, scope:String, contentType:String):void
[override]
RoundtripHandler
  
addObjectMapperAttribute(tag:Object, scope:String, serializer:ISerializer, deserializer:IDeserializer):void
[override]
RoundtripHandler
  
addSerializer(serializer:ISerializer):void
[override]
RoundtripHandler
  
Create a graph instance that can hold the data that is parsed in by this instance.
RoundtripHandler
  
handleError(fault:Fault):void
Deprecated: Use global or local fault event handler properties instead.
Callback that is invoked when the service request failed.
RoundtripHandler
  
handleResult(result:XML):void
Callback that is invoked when the server transferred the expected response.
RoundtripHandler
 Inherited
initialized(document:Object, id:String):void
Called automatically by the MXML compiler when the instance is created using an MXML tag.
AbstractRoundtripHandler
  
run(params:Object = null):void
Triggers a server round-trip.
RoundtripHandler
Protected Methods
 MethodDefined By
  
createAction(serviceName:String):ServerAction
Creates the ServerAction to use for sending the request to the server.
RoundtripHandler
 Inherited
Convenience method to create a graph which is configured (default styles, mappers) like the given graph and additionally has the mappers which are registered at this handler.
AbstractRoundtripHandler
 Inherited
Create and configure the GraphMLIOHandler instance that is used for reading the graph back in.
AbstractRoundtripHandler
  
Deprecated: Please Use createOutputIOHandler()
Deprecated.
RoundtripHandler
 Inherited
Create and configure the GraphMLIOHandler instance that is used for writing the graph structure.
AbstractRoundtripHandler
  
Create the parameters object that is transferred to the server.
RoundtripHandler
 Inherited
createParametersFromGraph(graph:IGraph, outputIOHandler:GraphMLIOHandler):Object
Convenience method to create the parameters object for a graph that is transferred to the server.
AbstractRoundtripHandler
  
dispatchGraphParsed(result:XML = null, graph:IGraph = null):void
Dispatches a graphParsed event containing the graph with the parsed data.
RoundtripHandler
  
dispatchRoundtripComplete(result:XML = null, graph:IGraph = null):void
Dispatches a roundtripComplete event containing the graph with the parsed data.
RoundtripHandler
  
dispatchXMLLoaded(result:XML = null, graph:IGraph = null):void
Dispatches a xmlLoaded event containing the received XML data.
RoundtripHandler
  
dispatchXMLResult(result:XML):void
Dispatches a XMLResultEvent containing the received XML data.
RoundtripHandler
  
doUpdate(newGraph:IGraph):void
Actually applies the new graph to the current graph in the GraphCanvas.
RoundtripHandler
  
onXmlGenerated(xml:XML):void
[override] Dispatches a RoundtripEvent.XML_SERIALIZED containing the serialized XML data.
RoundtripHandler
Events
 Event Summary Defined By
  Dispatched when the run method was called and a valid result is received.RoundtripHandler
   Dispatched after the GraphML was parsed.RoundtripHandler
   Dispatched after the roundtrip is completed and the new graph is stored in the GraphCanvasComponent graph.RoundtripHandler
   Dispatched when the response GraphML is completely loaded but not yet parsed.RoundtripHandler
   Dispatched when the graph is serialized as GraphML before sending.RoundtripHandler
Public Constants
 ConstantDefined By
  PARAM_ENCODING : String = graphEncoding
[static] The name of the request parameter which determines the graph encoding.
RoundtripHandler
  PARAM_GRAPH : String = graph
[static] The name of the request parameter which holds the GraphML string.
RoundtripHandler
  VALUE_COMPRESS : String = base64/zlib
[static] Indicates that the GraphML string which is sent to the server is compressed.
RoundtripHandler
  VALUE_URI_ENCODE : String = encodeURIComponent
[static] Indicates that the GraphML string which is sent to the server is URL encoded.
RoundtripHandler
Property Detail
adjustFontSizeproperty
adjustFontSize:Boolean[override]


Implementation
    public function get adjustFontSize():Boolean
    public function set adjustFontSize(value:Boolean):void
animateproperty 
animate:Boolean

Get or set whether the optional update of the current graph instance should be animated.

The default value is true.

This property can be used as the source for data binding.


Implementation
    public function get animate():Boolean
    public function set animate(value:Boolean):void
clearLocalGraphproperty 
clearLocalGraph:Boolean

Get or set whether the graph in the canvas should be cleared before the update. This is useful if the graph being loaded is a completely new graph and the ids might match ids of older entities.

The default value is false.

This property can be used as the source for data binding.


Implementation
    public function get clearLocalGraph():Boolean
    public function set clearLocalGraph(value:Boolean):void
customErrorHandlerproperty 
customErrorHandler:Function

A local custom error handler that will be used by this instance instead of the globalCustomErrorHandler.

A custom error handling delegate has to take a mx.rpc.events.ResultEvent as its single parameter.

The default value is null.

This property can be used as the source for data binding.


Implementation
    public function get customErrorHandler():Function
    public function set customErrorHandler(value:Function):void

See also

faultEventHandlerproperty 
faultEventHandler:Function

A local fault event handler that will be used by this instance instead of the globalFaultEventHandler.

A fault handling delegate has to take a mx.rpc.events.FaultEvent as its single parameter.

In order to prevent handling of the server response by the roundtrip handler that executed the request, stopImmediatePropagation() has to be called on the result event.

The default value is null.

This property can be used as the source for data binding.


Implementation
    public function get faultEventHandler():Function
    public function set faultEventHandler(value:Function):void

See also

fitContentOnUpdateproperty 
fitContentOnUpdate:Boolean

Gets or sets whether the canvas should fit the contents after the update if animation is disabled.

The default value is true.

This property can be used as the source for data binding.


Implementation
    public function get fitContentOnUpdate():Boolean
    public function set fitContentOnUpdate(value:Boolean):void
globalCustomErrorHandlerproperty 
globalCustomErrorHandler:Function

The static custom error handler that is used by all RoundtripHandlers, if no customErrorHandler is registered.

A custom error handling delegate has to take a mx.rpc.events.ResultEvent as its single parameter.

In order to prevent handling of the server response by the roundtrip handler that executed the request, stopImmediatePropagation() has to be called on the result event.

The default custom error handler expects the following format:

		    <?xml version="1.0" encoding="UTF-8"?>
		    <response>
		      <errors>
		        <error>
		          <![CDATA[
		            message
		          ]]>
		        </error>
		      </errors>
		    </response>
		   


Implementation
    public static function get globalCustomErrorHandler():Function
    public static function set globalCustomErrorHandler(value:Function):void

See also

globalFaultEventHandlerproperty 
globalFaultEventHandler:Function

The static fault event delegate that is used by all RoundtripHandlers, if no faultEventHandler is registered.

A fault handling delegate has to take a mx.rpc.events.FaultEvent as its single parameter.


Implementation
    public static function get globalFaultEventHandler():Function
    public static function set globalFaultEventHandler(value:Function):void

See also

graphCanvasproperty 
graphCanvas:GraphCanvasComponent

The graph canvas component that was passed for initialization of this instance.

This property can be used as the source for data binding.


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

Get or set the GraphMLIOhandler instance that will be used for GraphML input if update is set.

This property can be used as the source for data binding.


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

Get or set the GraphMLIOHandler instance that will be used for GraphML output if send is set.

This property can be used as the source for data binding.


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

The timeout in seconds for sent roundtrips. If the server doesn't respond after the set timeout a fault will be raised.

A value of 0 or less will prevent timeouts.

Note that for subsequent requests the timeout will not be overwritten if set to 0 or less.

The default value is 3600.


Implementation
    public function get requestTimeout():int
    public function set requestTimeout(value:int):void
sendproperty 
send:Boolean

Gets or sets whether the graph currently displayed in the graph canvas should be sent to the server.

The default value is true.

This property can be used as the source for data binding.


Implementation
    public function get send():Boolean
    public function set send(value:Boolean):void
sendOptionsproperty 
sendOptions:uint

Gets or sets the options to use for sending the graph to the server.

The options are specified using a combination of the various OPTION_COPY constants defined in GraphCanvasComponent.

This property can be used as the source for data binding.


Implementation
    public function get sendOptions():uint
    public function set sendOptions(value:uint):void
serviceNameproperty 
serviceName:String[override]


Implementation
    public function get serviceName():String
    public function set serviceName(value:String):void
updateproperty 
update:Boolean

Gets or sets whether the graph instance currently displayed in the graph canvas should be updated using the GraphML data sent by the server.

The default value is true.

This property can be used as the source for data binding.


Implementation
    public function get update():Boolean
    public function set update(value:Boolean):void
updateOptionsproperty 
updateOptions:uint

Get or set the options to use for the graph update.

The options are specified using a combination of the various OPTION_COPY constants defined in GraphCanvasComponent.

This property can be used as the source for data binding.


Implementation
    public function get updateOptions():uint
    public function set updateOptions(value:uint):void
Constructor Detail
RoundtripHandler()Constructor
public function RoundtripHandler(graphCanvas:GraphCanvasComponent = null, serviceName:String = roundtrip, options:uint = 0xFFFFFFFF)

Creates a new instance of the round trip handler for the given component.

Parameters
graphCanvas:GraphCanvasComponent (default = null) — The component to use for the roundtripping.

If this parameter is not set, the graphCanvas property has to be set before run() is called.

 
serviceName:String (default = roundtrip) — The service name to use for roundtripping. The service name is used in createAction to create a server action for the given service name.
 
options:uint (default = 0xFFFFFFFF) — An options object to use for sendOptions and updateOptions
Method Detail
addDeserializer()method
override public function addDeserializer(deserializer:IDeserializer):void

Parameters

deserializer:IDeserializer

addMapperAttribute()method 
override public function addMapperAttribute(tag:Object, name:String = null, scope:String, contentType:String):void

Parameters

tag:Object
 
name:String (default = null)
 
scope:String (default = NaN)
 
contentType:String (default = NaN)

addObjectMapperAttribute()method 
override public function addObjectMapperAttribute(tag:Object, scope:String, serializer:ISerializer, deserializer:IDeserializer):void

Parameters

tag:Object
 
scope:String
 
serializer:ISerializer
 
deserializer:IDeserializer

addSerializer()method 
override public function addSerializer(serializer:ISerializer):void

Parameters

serializer:ISerializer

createAction()method 
protected function createAction(serviceName:String):ServerAction

Creates the ServerAction to use for sending the request to the server. The action will use the handleResult method for the callback.

Listeners for the ResultEvent.RESULT and FaultEvent.FAULT are registered on the HTTPService instance with priority 60 and 40, respectively.

Parameters

serviceName:String — service name for the ServerAction

Returns
ServerAction — A readily configured ServerAction that uses the service name that was passed to the constructor.
createGraph()method 
public function createGraph():IGraph

Create a graph instance that can hold the data that is parsed in by this instance.

During a roundtrip, the graph instance is temporarily populated using the parsed GraphML data. The graph instance that is currently visualized in the graph canvas will be updated by comparing both graph instances.

Returns
IGraph — the created and configured graph instance

See also

createOuputIOHandler()method 
protected function createOuputIOHandler():GraphMLIOHandler
Deprecated: Please Use createOutputIOHandler()

Deprecated. Use createOutputIOHandler instead.

Returns
GraphMLIOHandler

See also

createOutputIOHandler()
createParameters()method 
protected function createParameters():Object

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 PARAM_GRAPH ("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 VALUE_COMPRESS ("base64/zlib") to the PARAM_ENCODING ("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 the PARAM_ENCODING ("graphEncoding") request parameter to VALUE_URI_ENCODE ("encodeURIComponent").

Returns
Object

See also

dispatchGraphParsed()method 
protected function dispatchGraphParsed(result:XML = null, graph:IGraph = null):void

Dispatches a graphParsed event containing the graph with the parsed data.

Parameters

result:XML (default = null)
 
graph:IGraph (default = null)

See also

dispatchRoundtripComplete()method 
protected function dispatchRoundtripComplete(result:XML = null, graph:IGraph = null):void

Dispatches a roundtripComplete event containing the graph with the parsed data.

Parameters

result:XML (default = null)
 
graph:IGraph (default = null)

See also

dispatchXMLLoaded()method 
protected function dispatchXMLLoaded(result:XML = null, graph:IGraph = null):void

Dispatches a xmlLoaded event containing the received XML data.

Parameters

result:XML (default = null)
 
graph:IGraph (default = null)

See also

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

Dispatches a XMLResultEvent containing the received XML data.

Parameters

result:XML

See also

doUpdate()method 
protected function doUpdate(newGraph:IGraph):void

Actually applies the new graph to the current graph in the GraphCanvas. This method is called by handleResult.x

In order to modify the updated graph before it is shown in the canvas, this method can be overridden.

If clearExistingGraph is set to true it clears the graphCanvass graph and copies the given graph into the graphCanvass graph with respect to the updateOptions. After the graph is copied, a roundtripComplete event is dispatched.

Parameters

newGraph:IGraph — the graph to apply to the current GraphCanvas.

handleError()method 
public function handleError(fault:Fault):void
Deprecated: Use global or local fault event handler properties instead.

Callback that is invoked when the service request failed.

Parameters

fault:FaultFault that describes the failure.

handleResult()method 
public function handleResult(result:XML):void

Callback that is invoked when the server transferred the expected response.

Dispatches the complete and the xmlLoaded event. If update is set to true it creates a new temporary graph, parses the GraphML using the inputIOHandler, dispatches a graphParsedevent and calls doUpdate

Parameters

result:XML — The xml content of the server response.

onXmlGenerated()method 
override protected function onXmlGenerated(xml:XML):void

Dispatches a RoundtripEvent.XML_SERIALIZED containing the serialized XML data.

Parameters

xml:XML

See also

run()method 
public function run(params:Object = null):void

Triggers a server round-trip.

If send is set, sends the current graph to the server. The GraphML data that will be sent to the server can be configured using sendOptions and addMapperAttribute.

If the update flag is set, the server is expected to send GraphML data that represents a new state of the currently displayed graph. The new state will be submitted to the current graph using the morphGraph method of GraphCanvasComponent. Whether the graph update will be animated can be set using the animate property.

This method will trigger an asynchronous call to the service url that was passed upon construction. The following hooks and events are available to be notified of the roundtrip progress:

Parameters

params:Object (default = null) — Additional parameters to be sent.

Important: The following parameter names are reserved for internal use:

  • graph
  • graphEncoding
  • encodeURIComponent

See also

Event Detail
complete Event
Event Object Type: com.yworks.remote.XMLResultEvent
XMLResultEvent.type property = com.yworks.remote.XMLResultEvent.COMPLETE

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

The event is dispatched before doUpdate is called.

Dispatched after a valid XML was received from the server. The received XML is stored in the xmlResult property.
graphParsed Event  
Event Object Type: com.yworks.remote.RoundtripEvent
RoundtripEvent.type property = com.yworks.remote.RoundtripEvent.GRAPH_PARSED

Dispatched after the GraphML was parsed.

Note that usually the graph is a temporary graph and not the visible graph. The graph can be retrieved in the graph property.

roundtripComplete Event  
Event Object Type: com.yworks.remote.RoundtripEvent
RoundtripEvent.type property = com.yworks.remote.RoundtripEvent.ROUNDTRIP_COMPLETE

Dispatched after the roundtrip is completed and the new graph is stored in the GraphCanvasComponent graph.

The graph can be retrieved in the graph property.

xmlLoaded Event  
Event Object Type: com.yworks.remote.RoundtripEvent
RoundtripEvent.type property = com.yworks.remote.RoundtripEvent.XML_LOADED

Dispatched when the response GraphML is completely loaded but not yet parsed.

The loaded XML can be retrieved in the xml property.

xmlSerialized Event  
Event Object Type: com.yworks.remote.RoundtripEvent
RoundtripEvent.type property = com.yworks.remote.RoundtripEvent.XML_SERIALIZED

Dispatched when the graph is serialized as GraphML before sending.

The serialized XML can be retrieved in the xml property.

Constant Detail
PARAM_ENCODINGConstant
public static const PARAM_ENCODING:String = graphEncoding

The name of the request parameter which determines the graph encoding.

PARAM_GRAPHConstant 
public static const PARAM_GRAPH:String = graph

The name of the request parameter which holds the GraphML string.

VALUE_COMPRESSConstant 
public static const VALUE_COMPRESS:String = base64/zlib

Indicates that the GraphML string which is sent to the server is compressed.

This value is sent as value of the PARAM_ENCODING parameter.

VALUE_URI_ENCODEConstant 
public static const VALUE_URI_ENCODE:String = encodeURIComponent

Indicates that the GraphML string which is sent to the server is URL encoded.

This value is sent as value of the PARAM_ENCODING parameter.