Class ActionServlet

  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.yworks.yfiles.server.tiles.servlet.action.ActionServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ActionServlet
extends javax.servlet.http.HttpServlet

The action servlet dispatches custom actions to handlers. Custom actions are implemented by (ActionHandler) implementations.

See Also:
Serialized Form

Constructor Summary
Method Summary
protected  ActionContext createContext(javax.servlet.http.HttpServletRequest request)
          creates a new action context instance from the given request.
protected  ClientControl createControl(ActionContext context)
          creates a new client control instance from an action context.
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          calls the appropriate action handler for the request and writes the response.
 ActionHandler getActionHandler(String id)
          returns the action handler registered for the given id.
 ActionHandler registerActionHandler(String id, ActionHandler handler)
          registers an action handler instance for an id.
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ActionServlet()
Method Detail


public ActionHandler registerActionHandler(String id,
                                           ActionHandler handler)
registers an action handler instance for an id. Normally there is no need to call this method from client code. Add your action handlers as initialization parameters of the action servlet instead.

id - a string
handler - the handler for requests to the action servlet with the given id
the handler which was previously registered for the id or null
See Also:


public ActionHandler getActionHandler(String id)
returns the action handler registered for the given id. If there is no action handler registered for the id, but there is an initialization parameter id for the action servlet, then its value is interpreted as the fully qualified class name of an action handler and a new instance of this handler is constructed using the default constructor. The new instance is then registered for the id and returned.

id - a string
an action handler registered for the given id or null


protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException,
calls the appropriate action handler for the request and writes the response. If the request has no "id" parameter or there is no action handler registered for the "id" parameter value the state of the response is set to 404. Otherwise an ActionContext and a ClientControl instance are created and passed to the ActionHandler.handleAction(ActionContext, ClientControl) method of the action handler. If a runtime exception occurs during the execution of the handler the response state is set to 500. If the action handler succeeds a response is written to the client which contains the information as configured in the client control.

request - the request from a client
response - the response to be sent to the client
IOException - if I/O problems occur
javax.servlet.ServletException - if servlet related problems occur


protected ActionContext createContext(javax.servlet.http.HttpServletRequest request)
creates a new action context instance from the given request.

request - a client request for the action servlet
returns a new action context initialized from the request


protected ClientControl createControl(ActionContext context)
creates a new client control instance from an action context. The settings for graph name, graph, updating world bounds, hit test info, hierarchy info, nodes and edges are initialized from the corresponding context settings. They can be changed by the action handler when it accesses the control in its ActionHandler.handleAction(ActionContext, ClientControl) method.

context - the action context for an action servlet request
returns a new client control initialized from the given action context

Copyright © 2006-2013 yWorks GmbH. All rights reserved