com.yworks.yfiles.server.tiles.servlet.action
Class ActionServlet

java.lang.Object
  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
ActionServlet()
           
 
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

ActionServlet

public ActionServlet()
Method Detail

registerActionHandler

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.

Parameters:
id - a string
handler - the handler for requests to the action servlet with the given id
Returns:
the handler which was previously registered for the id or null
See Also:
getActionHandler(String)

getActionHandler

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.

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

doPost

protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException,
                      IOException
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.

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

createContext

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

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

createControl

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.

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


Copyright © 2006-2013 yWorks GmbH. All rights reserved