yfiles.client.tiles.ServerAction
Class ServerAction

This class is a wrapper for a server side action.

An instance of this class specifies an action on the server side and the client side environment in which it gets executed. The run function calls the server side using an AJAX POST request. If the server side call was successful, the client side is updated to reflect the changes on the server side.

The constructor creates a new instance from the given parameter object. Recognized parameters names are the following. All entries are optional except for the id entry. There are also getters and setters for the parameters. See the comments for the setters for more information.

id the id of the server side action
url the URL of the ActionServlet (default ./yFilesAction)
graphName the name of the graph for the action
graph the graph for the action
canvas a GraphCanvas to be refreshed
hitTest a HitTest to be updated
hierarchy a HierarchyManager to be updated
selection a selection to be updated
clientContext can be used as a "marker" to identify a particular ServerAction
customParameter is sent to the server side action
preRun a function, which is called in the scope of this ServerAction instance before the request is sent to the server
postRun a function, which is called in the scope of this ServerAction instance after the response arrived from the server
error a function, which is called in the scope this ServerAction instance, if the request resulted in a server side error

 
Constructor Summary
ServerAction(/*Object*/ kwArgs)
           This class is a wrapper for a server side action.
 
Method Summary
 GraphCanvas getCanvas()
          returns the canvas which is available for this instance.
 anything getClientContext()
          returns what was set with setClientContext.
 String getCustomParameter()
          returns the custom parameter.
 String getCustomResponse()
          returns the custom response from the server side action, if there is one.
 Function getErrorHandler()
          returns the callback which gets executed when a server error occurred for the request made by run().
 Graph getGraph()
          returns the graph which is available for this instance.
 String getGraphName()
          returns the graph name which is available for this instance.
 HierarchyManager getHierarchyManager()
          returns the hierarchy manager which is available for this instance.
 HitTest getHitTest()
          returns the hit test which is available for this instance.
 String getId()
          returns the id used for server requests.
 Function getPostRun()
          returns the callback which gets executed last when the request made run() was successful.
 Function getPreRun()
          returns the callback which gets executed first when run() is called.
 GraphSelection getSelection()
          returns the selection which is available for this instance.
 String getUrl()
          returns the URL used for server requests (default "./yFilesAction").
  getWorldBounds()
          returns the new world bounds of the graph the action dealt with on the server side.
  run()
          performs the action specified by this instance.
  setCanvas(/*GraphCanvas*/ canvas)
          sets the canvas which is available for this instance.
  setClientContext(/*anything*/ clientContext)
          stores clientContext at this instance.
  setCustomParameter(/*String*/ customParameter)
          sets the custom parameter.
  setErrorHandler(/*Function*/ errorHandler)
          sets the callback which gets executed when a server error occurred for the request made by run().
  setGraph(/*Graph*/ graph)
          sets the graph which is available for this instance.
  setGraphName(/*String*/ name)
          sets the symbolic name for the graph to be used on the server side.
  setHierarchyManager(/*HierarchyManager*/ hierarchy)
          sets the hierarchy manager which is available for this instance.
  setHitTest(/*HitTest*/ hitTest)
          sets the hit test which is available for this instance.
  setId(/*String*/ id)
          sets the id used for server requests.
  setPostRun(/*Function*/ postRun)
          sets the callback which gets executed last when the request made run() was successful.
  setPreRun(/*Function*/ preRun)
          sets the callback which gets executed first when run() is called.
  setSelection(/*GraphSelection*/ selection)
          sets the selection which is available for this instance.
  setUrl(/*String*/ url)
          sets the URL used for server requests.
 
Constructor Detail

ServerAction

ServerAction(/*Object*/ kwArgs)
This class is a wrapper for a server side action.
An instance of this class specifies an action on the server side and the client side environment in which it gets executed. The run function calls the server side using an AJAX POST request. If the server side call was successful, the client side is updated to reflect the changes on the server side.

The constructor creates a new instance from the given parameter object. Recognized parameters names are the following. All entries are optional except for the id entry. There are also getters and setters for the parameters. See the comments for the setters for more information.

id the id of the server side action
url the URL of the ActionServlet (default ./yFilesAction)
graphName the name of the graph for the action
graph the graph for the action
canvas a GraphCanvas to be refreshed
hitTest a HitTest to be updated
hierarchy a HierarchyManager to be updated
selection a selection to be updated
clientContext can be used as a "marker" to identify a particular ServerAction
customParameter is sent to the server side action
preRun a function, which is called in the scope of this ServerAction instance before the request is sent to the server
postRun a function, which is called in the scope of this ServerAction instance after the response arrived from the server
error a function, which is called in the scope this ServerAction instance, if the request resulted in a server side error
Parameters:
kwArgs -
Method Detail

getCanvas

GraphCanvas getCanvas()
returns the canvas which is available for this instance.
If the canvas is available, it gets refreshed whenever run() was successfully called unless the server side action overrides this default behavior.

getClientContext

anything getClientContext()
returns what was set with setClientContext.

getCustomParameter

String getCustomParameter()
returns the custom parameter.

getCustomResponse

String getCustomResponse()
returns the custom response from the server side action, if there is one.

getErrorHandler

Function getErrorHandler()
returns the callback which gets executed when a server error occurred for the request made by run().

getGraph

Graph getGraph()
returns the graph which is available for this instance.
The graph can be set directly using setGraph. A graph is also available, if it has not been set directly, but a canvas or a hierarchy manager has been set. In this case the graph of the canvas or hierarchy manager is available.

getGraphName

String getGraphName()
returns the graph name which is available for this instance.
The graph name can be set directly using setGraphName. If the graph name was not set directly, but a graph or a hit test is available, then the name of that graph or the graph name from the hit test is returned.

getHierarchyManager

HierarchyManager getHierarchyManager()
returns the hierarchy manager which is available for this instance.
If the hierarchy manager is available, it gets updated whenever run() was successfully called unless the server side action overrides this default behavior.

getHitTest

HitTest getHitTest()
returns the hit test which is available for this instance.
The hit test can be set directly using setHitTest. A hit test is also available, if it has not been set directly, but a canvas has been set. In this case the hit test of the canvas is available. If the hit test is available, it gets updated whenever run() was successfully called unless the server side action overrides this default behavior.

getId

String getId()
returns the id used for server requests.

getPostRun

Function getPostRun()
returns the callback which gets executed last when the request made run() was successful.

getPreRun

Function getPreRun()
returns the callback which gets executed first when run() is called.

getSelection

GraphSelection getSelection()
returns the selection which is available for this instance.
If a selection is available, its contents is sent to the server when run() is called. If the server action returns successfully and the selection is available, it gets updated with the data sent from the server unless the server side action overrides this default behavior.

getUrl

String getUrl()
returns the URL used for server requests (default "./yFilesAction").

getWorldBounds

getWorldBounds()
returns the new world bounds of the graph the action dealt with on the server side.

run

run()
performs the action specified by this instance.
  1. First the preRun callback is executed, if it exists. If it returns false, run returns without calling the server (neither the postRun callback nor the error handler are called in this case).
  2. The contents for the request to the server is assembled. It is the information on the client state which is accessible later on by the server side action handler.
  3. The AJAX POST request is sent to the server and run returns since it is an asynchronous request.
  4. When the server reponse arrives and if no server error occurred...
    1. the client is updated according to the availability of things like a hit test or a selection and the server side settings,
    2. and the postRun callback is executed.
  5. If the server request results in an error, the error handler is called. No client side updates are performed and the postRun callback is not called.

setCanvas

setCanvas(/*GraphCanvas*/ canvas)
sets the canvas which is available for this instance.
Parameters:
canvas -

setClientContext

setClientContext(/*anything*/ clientContext)
stores clientContext at this instance.
The client context is not sent to the server. It can be retrieved with getClientContext. Its purpose is to associate extra client side information with a particular ServerAction instance.
Parameters:
clientContext - you want to remember for this instance

setCustomParameter

setCustomParameter(/*String*/ customParameter)
sets the custom parameter.
The custom parameter is sent to the server side action.
Parameters:
customParameter -

setErrorHandler

setErrorHandler(/*Function*/ errorHandler)
sets the callback which gets executed when a server error occurred for the request made by run().
Parameters:
errorHandler -

setGraph

setGraph(/*Graph*/ graph)
sets the graph which is available for this instance.
Parameters:
graph -

setGraphName

setGraphName(/*String*/ name)
sets the symbolic name for the graph to be used on the server side.
Parameters:
name -

setHierarchyManager

setHierarchyManager(/*HierarchyManager*/ hierarchy)
sets the hierarchy manager which is available for this instance.
Parameters:
hierarchy -

setHitTest

setHitTest(/*HitTest*/ hitTest)
sets the hit test which is available for this instance.
Parameters:
hitTest -

setId

setId(/*String*/ id)
sets the id used for server requests.
Parameters:
id -

setPostRun

setPostRun(/*Function*/ postRun)
sets the callback which gets executed last when the request made run() was successful.
Parameters:
postRun -

setPreRun

setPreRun(/*Function*/ preRun)
sets the callback which gets executed first when run() is called.
The given function is called witout arguments and is expected to return a boolean. If it returns false, the server request will be canceled.
Parameters:
preRun -

setSelection

setSelection(/*GraphSelection*/ selection)
sets the selection which is available for this instance.
Parameters:
selection -

setUrl

setUrl(/*String*/ url)
sets the URL used for server requests.
Parameters:
url -

Copyright © 2006-2011 yWorks GmbH. All rights reserved.