Packagecom.yworks.remote
Classpublic class RoundtripHandler
InheritanceRoundtripHandler Inheritance flash.events.EventDispatcher
ImplementsResultHandler

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.



Public Properties
 PropertyDefined by
  additionalParameters : Object
Get or set an Object containing additional parameters that should be send to the server.
RoundtripHandler
  animate : Boolean
Get or set whether the optional update of the current graph instance should be animated.
RoundtripHandler
  clearLocalGraph : Boolean
Get or set whether the graph in the canvas should be cleared before the update.
RoundtripHandler
  compress : Boolean
Whether to use compression for the graphml data that is sent to the server.
RoundtripHandler
  fitContentOnUpdate : Boolean
Gets or sets whether the canvas should fit the contents after the update if animation is disabled.
RoundtripHandler
  inputIOHandler : GraphMLIOHandler
Get or set the GraphMLIOhandler instance that will be used for GraphML input if update is set.
RoundtripHandler
  outputIOHandler : GraphMLIOHandler
Get or set the GraphMLIOHandler instance that will be used for GraphML output if send is set.
RoundtripHandler
  send : Boolean
Gets or sets whether the graph currently displayed in the graph canvas should be sent to the server.
RoundtripHandler
  sendOptions : uint
Gets or sets the options to use for sending the graph to the server.
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
  uriEncode : Boolean
Whether to encode the graphML string sent to the server using the global encodeURIComponent function.
RoundtripHandler
  useJavaStyles : Boolean
RoundtripHandler
Protected Properties
 PropertyDefined by
  graphCanvas : GraphCanvasComponent
[read-only]
RoundtripHandler
Public Methods
 MethodDefined by
  
RoundtripHandler(graphCanvas:GraphCanvasComponent, serviceName:String = "roundtrip", options:uint = 255)
Creates a new instance of the round trip handler for the given component.
RoundtripHandler
  
addDeserializer(deserializer:IDeserializer):void
Adds another IDeserializer instance to a list that will be registered with the created the inputIOHandler.
RoundtripHandler
  
addMapperAttribute(tag:Object, name:String = null, scope:String, contentType:String):void
Add a graph item attribute that should be considered for input and output.
RoundtripHandler
  
Create a graph instance that can hold the data that is parsed in by this instance.
RoundtripHandler
  
handleError(fault:Fault):void
Callback that is invoked when the service request failed.
RoundtripHandler
  
handleResult(result:XML):void
Callback that is invoked when the server transfered the expected response.
RoundtripHandler
  
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
  
Create and configure the GraphMLIOHandler instance that is used for reading the graph back in.
RoundtripHandler
  
Create and configure the GraphMLIOHandler instance that is used for writing the graph structure.
RoundtripHandler
  
Create the parameters object that is transferred to the server.
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
Events
 EventSummaryDefined by
   Dispatched when the run method was called and a valid result is received.RoundtripHandler
Property detail
additionalParametersproperty
additionalParameters:Object  [read-write]

Get or set an Object containing additional parameters that should be send to the server.

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

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

Implementation
    public function get animate():Boolean
    public function set animate(value:Boolean):void
clearLocalGraphproperty 
clearLocalGraph:Boolean  [read-write]

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 <code>false</code>.

Implementation
    public function get clearLocalGraph():Boolean
    public function set clearLocalGraph(value:Boolean):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

See also

fitContentOnUpdateproperty 
fitContentOnUpdate:Boolean  [read-write]

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

The default value is true.

Implementation
    public function get fitContentOnUpdate():Boolean
    public function set fitContentOnUpdate(value:Boolean):void
graphCanvasproperty 
graphCanvas:GraphCanvasComponent  [read-only]

Implementation
    protected function get graphCanvas():GraphCanvasComponent
inputIOHandlerproperty 
inputIOHandler:GraphMLIOHandler  [read-write]

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

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

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

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

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

The default value is true.

Implementation
    public function get send():Boolean
    public function set send(value:Boolean):void
sendOptionsproperty 
sendOptions:uint  [read-write]

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.

Implementation
    public function get sendOptions():uint
    public function set sendOptions(value:uint):void
updateproperty 
update:Boolean  [read-write]

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.

Implementation
    public function get update():Boolean
    public function set update(value:Boolean):void
updateOptionsproperty 
updateOptions:uint  [read-write]

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.

Implementation
    public function get updateOptions():uint
    public function set updateOptions(value:uint):void
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

useJavaStylesproperty 
useJavaStyles:Boolean  [read-write]Implementation
    public function get useJavaStyles():Boolean
    public function set useJavaStyles(value:Boolean):void
Constructor detail
RoundtripHandler()constructor
public function RoundtripHandler(graphCanvas:GraphCanvasComponent, serviceName:String = "roundtrip", options:uint = 255)

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

Parameters
graphCanvas:GraphCanvasComponent — The component to use for the roundtripping.
 
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 = 255) — An options object to use for sendOptions and updateOptions
Method detail
addDeserializer()method
public function addDeserializer(deserializer:IDeserializer):void

Adds another IDeserializer instance to a list that will be registered with the created the inputIOHandler.

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

Add a graph item attribute that should be considered for input and output.

Parameters
tag:Object — The attribute tag. the attribute mapper has to be registered in the graph's mapper registry with this tag.
 
name:String (default = null) — The name that should be used for the graphml attr.name attribute.
 
scope:String — The scope type of the attribute. One of
  • GraphMLConstants.SCOPE_NODE
  • GraphMLConstants.SCOPE_EDGE
  • GraphMLConstants.SCOPE_PORT
  • GraphMLConstants.SCOPE_GRAPH
  • GraphMLConstants.SCOPE_GRAPHML
  • GraphMLConstants.SCOPE_ALL
 
contentType:String — The attribute content type. One of
  • GraphMLConstants.TYPE_STRING
  • GraphMLConstants.TYPE_LONG
  • GraphMLConstants.TYPE_INT
  • GraphMLConstants.TYPE_FLOAT
  • GraphMLConstants.TYPE_DOUBLE
  • GraphMLConstants.TYPE_BOOLEAN
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.

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

createInputIOHandler()method 
protected function createInputIOHandler():GraphMLIOHandler

Create and configure the GraphMLIOHandler instance that is used for reading the graph back in.

The default input I/O handler will be able to read both the native yFiles FLEX GraphML format and yFiles Java GraphML data.

Returns
GraphMLIOHandler — the configured GraphMLIOHandler instance
createOutputIOHandler()method 
protected function createOutputIOHandler():GraphMLIOHandler

Create and configure the GraphMLIOHandler instance that is used for writing the graph structure.

The default output I/O handler will use the yFiles FLEX native GraphML format for serialization of graph item visualizations. To write the style information in a yFiles Java compatible format, use a com.yworks.io.graphml.JavaCompatGraphMLIOHandler instead.

Returns
GraphMLIOHandler — the configured GraphMLIOHandler instance
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 "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".

Returns
Object

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.

Parameters
newGraph:IGraph — the graph to apply to the current GraphCanvas.
handleError()method 
public function handleError(fault:Fault):void

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 transfered the expected response.

Parameters
result:XML — The xml content of the server response.
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 an 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:

  • The handleResult method of this instance is called when a XML result is received from the server.
  • The "complete" event dispatched by this RoundtripHandler instance When a XML result is received from the server. The event is of type XMLResultEvent and is dispatched before doUpdate is called.
  • The doUpdate method of this instance is called after the GraphML data received from the server has been parsed.
  • The "graphChanged" event dispatched by the inputIOHandler after the GraphML data received from the server has been parsed. The event is of type GraphEvent.
  • The "morphStart" end "morphEnd" events dispatched by the GraphCanvasComponent instance that was passed upon construction. The events are dispatched before and after the graph structure is updated, respectively. The events are always dispatched, no matter whether the graph structure update is animated or not.

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

See also

Event detail
completeevent 
Event object type: com.yworks.remote.XMLResultEvent

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

The event is dispatched before doUpdate is called.