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.

 
Constructor Summary
ServerAction(Object kwArgs)
           

This class is a wrapper for a server side action.

 
Method Summary
 yfiles/client/tiles/widget/GraphCanvas getCanvas()           

returns the canvas which is available for this instance.

 anyhting getClientContext()           

returns what was set with setClientContext.

 undefined 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().

 yfiles/client/tiles/Graph getGraph()           

returns the graph which is available for this instance.

 String getGraphName()           

returns the graph name which is available for this instance.

 yfiles/client/tiles/HierarchyManager getHierarchyManager()           

returns the hierarchy manager which is available for this instance.

 yfiles/client/tiles/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.

 yfiles/client/tiles/GraphSelection getSelection()           

returns the selection which is available for this instance.

 String getUrl()           

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

 Object 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(yfiles/client/tiles/widget/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(yfiles/client/tiles/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(yfiles/client/tiles/HierarchyManager hierarchy)           

sets the hierarchy manager which is available for this instance.

  setHitTest(yfiles/client/tiles/HitTest hitTest)           

sets the hit test which is available for this instance.

  setId(String id)           
  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(yfiles/client/tiles/GraphSelection selection)           

sets the selection which is available for this instance.

  setUrl(String url)           
 
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

yfiles/client/tiles/widget/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

anyhting getClientContext()

returns what was set with setClientContext.


getCustomParameter

undefined 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

yfiles/client/tiles/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

yfiles/client/tiles/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

yfiles/client/tiles/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

yfiles/client/tiles/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

Object 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(yfiles/client/tiles/widget/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 -

anything 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(yfiles/client/tiles/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(yfiles/client/tiles/HierarchyManager hierarchy)

sets the hierarchy manager which is available for this instance.

Parameters:
hierarchy -

setHitTest

 setHitTest(yfiles/client/tiles/HitTest hitTest)

sets the hit test which is available for this instance.

Parameters:
hitTest -

The hit test instance


setId

 setId(String id)
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(yfiles/client/tiles/GraphSelection selection)

sets the selection which is available for this instance.

Parameters:
selection -

yfiles/client/tiles/GraphSelection


setUrl

 setUrl(String url)
Parameters:
url -

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