| Package | com.yworks.remote |
| Class | public class RoundtripHandler |
| Inheritance | RoundtripHandler AbstractRoundtripHandler flash.events.EventDispatcher |
| Implements | ResultHandler, mx.core.IMXMLObject |
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:
xmlSerialized before the GraphML is sent. The
GraphML can be found in the event's xml property.xmlLoaded after the GraphML is completely loaded. The
GraphML can be found in the event's xml property.graphParsed after the GraphML is parsed into the temporary graph. The
temporary graph can be found in the event's graph property.
At this point, the temporary graph is not visible and theoriginal graph
is still unaffected. One can use this event to make changes to the graph
before it is displayed.roundtripComplete after temporary graph is copied to the
visible graph. The visible graph can be found in the event's graph
property. After this event is dispatched, the roundtrip is complete.Instances of this class can be created in Actionscript as well as in MXML: Actionscript:
var roundtrip:RoundtripHandler = new RoundtripHandler(graphCanvas, "service");
Hide MXML Syntax| Property | Defined By | ||
|---|---|---|---|
![]() | additionalParameters : 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 | ||
![]() | autoReadMapperData : Boolean
Whether mapper data contained in the GraphML data should be automatically
deserialized and registered with the graph's mapper registry. | AbstractRoundtripHandler | |
![]() | autoWriteMapperData : 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 | ||
![]() | compress : 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 | ||
![]() | localViewMode : Boolean
Whether to read/write only the local view for folded graphs. | AbstractRoundtripHandler | |
![]() | mapperAttributes : 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 | ||
![]() | readPortLayout : 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 | ||
![]() | sendLocalRoot : 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 | ||
![]() | uriEncode : Boolean
Whether to encode the graphML string sent to
the server using the global encodeURIComponent function. | AbstractRoundtripHandler | |
![]() | useJavaStyles : Boolean
Whether to use style implementations that were
created for compatibility with the yFiles Java realizers. | AbstractRoundtripHandler | |
| Method | Defined 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 | ||
![]() | 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 | ||
| Method | Defined By | ||
|---|---|---|---|
createAction(serviceName:String):ServerAction
Creates the ServerAction to use for sending the request to the server. | RoundtripHandler | ||
![]() |
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 | |
![]() |
Create and configure the GraphMLIOHandler instance that is used for reading the graph back in. | AbstractRoundtripHandler | |
Deprecated: Please Use createOutputIOHandler()
Deprecated. | RoundtripHandler | ||
![]() |
Create and configure the GraphMLIOHandler instance that is used for writing the graph structure. | AbstractRoundtripHandler | |
createParameters():Object
Create the parameters object that is transferred to the server. | RoundtripHandler | ||
![]() |
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 | ||
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 | ||
| 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 | |||
| Constant | Defined 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 | ||
| adjustFontSize | property |
adjustFontSize:Boolean[override]
public function get adjustFontSize():Boolean public function set adjustFontSize(value:Boolean):void| animate | property |
animate:BooleanGet 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.
public function get animate():Boolean public function set animate(value:Boolean):void| clearLocalGraph | property |
clearLocalGraph:BooleanGet 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.
public function get clearLocalGraph():Boolean public function set clearLocalGraph(value:Boolean):void| customErrorHandler | property |
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.
public function get customErrorHandler():Function public function set customErrorHandler(value:Function):voidSee also
| faultEventHandler | property |
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.
public function get faultEventHandler():Function public function set faultEventHandler(value:Function):voidSee also
| fitContentOnUpdate | property |
fitContentOnUpdate:BooleanGets 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.
public function get fitContentOnUpdate():Boolean public function set fitContentOnUpdate(value:Boolean):void| globalCustomErrorHandler | property |
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>
public static function get globalCustomErrorHandler():Function public static function set globalCustomErrorHandler(value:Function):voidSee also
| globalFaultEventHandler | property |
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.
public static function get globalFaultEventHandler():Function public static function set globalFaultEventHandler(value:Function):voidSee also
| graphCanvas | property |
graphCanvas:GraphCanvasComponentThe graph canvas component that was passed for initialization of this instance.
This property can be used as the source for data binding.
public function get graphCanvas():GraphCanvasComponent public function set graphCanvas(value:GraphCanvasComponent):void| inputIOHandler | property |
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.
public function get inputIOHandler():GraphMLIOHandler public function set inputIOHandler(value:GraphMLIOHandler):void| outputIOHandler | property |
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.
public function get outputIOHandler():GraphMLIOHandler public function set outputIOHandler(value:GraphMLIOHandler):void| requestTimeout | property |
requestTimeout:intThe 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.
public function get requestTimeout():int public function set requestTimeout(value:int):void| send | property |
send:BooleanGets 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.
public function get send():Boolean public function set send(value:Boolean):void| sendOptions | property |
sendOptions:uintGets 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.
public function get sendOptions():uint public function set sendOptions(value:uint):void| serviceName | property |
serviceName:String[override]
public function get serviceName():String public function set serviceName(value:String):void| update | property |
update:BooleanGets 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.
public function get update():Boolean public function set update(value:Boolean):void| updateOptions | property |
updateOptions:uintGet 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.
public function get updateOptions():uint public function set updateOptions(value:uint):void| 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.
ParametersgraphCanvas:GraphCanvasComponent (default = null) — The component to use for the roundtripping.
If this parameter is not set, the | |
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
|
| 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
|
ServerAction — A readily configured ServerAction that uses the service name that was passed to the constructor.
|
| createGraph | () | method |
public function createGraph():IGraphCreate 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.
ReturnsIGraph — the created and configured graph instance
|
See also
| createOuputIOHandler | () | method |
protected function createOuputIOHandler():GraphMLIOHandler
Deprecated. Use createOutputIOHandler instead.
GraphMLIOHandler |
See also
| createParameters | () | method |
protected function createParameters():ObjectCreate 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").
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):voidActually 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):voidCallback that is invoked when the service request failed.
Parameters
fault:Fault — Fault that describes the failure.
|
| handleResult | () | method |
public function handleResult(result:XML):voidCallback 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):voidTriggers 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:
handleResult method of this instance is called when a XML result
is received from the server.RoundtripHandler instance
when a XML result is received from the server. The event is of type XMLResultEvent
and is dispatched before doUpdate is called.
This event correlates with the "xmlLoaded" event.
RoundtripHandler instance
when a XML result is received from the server. The event is of type
RoundtripEvent and is dispatched before doUpdate is called.
inputIOHandler after the
GraphML data received from the server has been parsed. The event is of type
GraphEvent.
This event correlates with the "graphParsed" event.
RoundtripHandler instance
after GraphML data received from the server has been parsed. The event is of type
RoundtripEvent and is dispatched before doUpdate is called.
doUpdate method of this instance is called after the GraphML data received from the
server has been parsed.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.
The "morphEnd" event correlates with the "roundtripComplete" event.RoundtripHandler.
This event is dispatched after the GraphCanvasComponent's graph
is updated and the roundtrip process is complete.Parameters
params:Object (default = null) — Additional parameters to be sent.
Important: The following parameter names are reserved for internal use:
|
See also
| complete | Event |
com.yworks.remote.XMLResultEventcom.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.
XML was received from the server.
The received XML is stored in the xmlResult property.
| graphParsed | Event |
com.yworks.remote.RoundtripEventcom.yworks.remote.RoundtripEvent.GRAPH_PARSEDDispatched 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 |
com.yworks.remote.RoundtripEventcom.yworks.remote.RoundtripEvent.ROUNDTRIP_COMPLETEDispatched 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 |
com.yworks.remote.RoundtripEventcom.yworks.remote.RoundtripEvent.XML_LOADEDDispatched when the response GraphML is completely loaded but not yet parsed.
The loaded XML can be retrieved in the xml property.
| xmlSerialized | Event |
com.yworks.remote.RoundtripEventcom.yworks.remote.RoundtripEvent.XML_SERIALIZEDDispatched when the graph is serialized as GraphML before sending.
The serialized XML can be retrieved in the xml property.
| PARAM_ENCODING | Constant |
public static const PARAM_ENCODING:String = graphEncodingThe name of the request parameter which determines the graph encoding.
| PARAM_GRAPH | Constant |
public static const PARAM_GRAPH:String = graphThe name of the request parameter which holds the GraphML string.
| VALUE_COMPRESS | Constant |
public static const VALUE_COMPRESS:String = base64/zlibIndicates 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_ENCODE | Constant |
public static const VALUE_URI_ENCODE:String = encodeURIComponentIndicates that the GraphML string which is sent to the server is URL encoded.
This value is sent as value of the PARAM_ENCODING parameter.