jodd.servlet
Class ActionController

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byjodd.servlet.ActionServlet
              extended byjodd.servlet.ActionController
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ActionController
extends ActionServlet

Represents a controller part of mvc2 framework.

During initialization, configuration xml file is read and all data are loaded by controller. When request is received, controller will lookup for the adequate ActionServlet.doAction() or defined mapped method to invoke. Depending of the resulting string and the configuration, controller will perform forwarding or redirection to the destination view.

Controller allows intercepting of all invoked actions, by using the ActionFilter.

See Also:
ActionServlet, ActionFilter, Serialized Form

Field Summary
static java.lang.String ACTION_DATA
          Unique request parameter name that holds ActionData for the current invoked action, as defined in the configuration xml file.
static java.lang.String ACTION_NOT_FOUND
          Unique global forward name that will be used in case when action is not mapped to a request.
static java.lang.String ACTION_PATH
          Unique request parameter name that holds action path of the the current invoked action, as defined in the configuration xml file.
static java.lang.String INVOKE_ACTION_PARAMS
          Unique global forward name that will be used in case when action is not mapped to a request.
 
Fields inherited from class jodd.servlet.ActionServlet
parameterActionName, parameterForwardName, parameterRedirectName
 
Constructor Summary
ActionController()
           
 
Method Summary
 void doRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Request dispatcher - the controller.
 void init(javax.servlet.ServletConfig config)
          Initialization of the controler.
 java.lang.String invokeAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String actionPath)
          Invoke specified action as it would be invoked by ActionController.
 void reload()
          Reloads configuration XML files.
 
Methods inherited from class jodd.servlet.ActionServlet
doAction, doGet, doPost, forward, forwardParam, forwardParam, getActionForwardPath, getActionMethodName, getActionParameter, getActionPath, getActionType, getController, invokeAction, invokeExternalAction, isActionForwardRedirect, redirect, redirectParam, redirectParam
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_DATA

public static java.lang.String ACTION_DATA
Unique request parameter name that holds ActionData for the current invoked action, as defined in the configuration xml file. It is used internally.

See Also:
ActionData

ACTION_PATH

public static java.lang.String ACTION_PATH
Unique request parameter name that holds action path of the the current invoked action, as defined in the configuration xml file. It is used internally.


ACTION_NOT_FOUND

public static java.lang.String ACTION_NOT_FOUND
Unique global forward name that will be used in case when action is not mapped to a request.


INVOKE_ACTION_PARAMS

public static java.lang.String INVOKE_ACTION_PARAMS
Unique global forward name that will be used in case when action is not mapped to a request.

Constructor Detail

ActionController

public ActionController()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initialization of the controler. Reads all actions xml configuration files and populates actionsMap; and initialize ActionFilter if defined.

Parameters:
config - actionsMap
Throws:
javax.servlet.ServletException
See Also:
reload()

reload

public void reload()
            throws javax.servlet.ServletException
Reloads configuration XML files. This method should be used in developement, since it is not synchronized with the main dispatcher. It re-reads configuration files and resets all ActionServlet settings, while server and controller are active. This makes posible to change configuration without restarting server.

Throws:
javax.servlet.ServletException

doRequest

public void doRequest(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws java.io.IOException,
                      javax.servlet.ServletException
Request dispatcher - the controller.

The request uri will be processed first. Controller will try to find specific Action type (defined in actions xml configuration file). Very first time when action is required its class (child of ActionServlet) will be loaded and instanced. Next time, actions instance will be found in the buffer, so actions will be instanced just once (when accessed first time).

If Action can not be found, controller will forward to ACTION_NOT_FOUND global forward mapping.

Method doAction() will be invoked on founded action. This method returns a string that represents a forward name (defined in actions xml configuration file). Alternatively, if defined so, mapped method will be invoked.

On the end, controller will perform forward or redirection to path defined with returned forward name string (that doAction() returns), as defined in configuration file. If forward name can not be found, then global forwards will be examined. If global forward can not be found, that it is assumed that no forwards are used, and that returned string represents a page.

Overrides:
doRequest in class ActionServlet
Parameters:
request -
response -
Throws:
java.io.IOException
javax.servlet.ServletException
See Also:
ActionServlet.doAction(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

invokeAction

public java.lang.String invokeAction(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     java.lang.String actionPath)
                              throws java.io.IOException,
                                     javax.servlet.ServletException
Invoke specified action as it would be invoked by ActionController.

NOTE: request parameters are passed from the current request!!! Instead, they are passed as a HashMap in request attribute under the key: INVOKE_ACTION_PARAMS.

Overrides:
invokeAction in class ActionServlet
Parameters:
request - http request
response - http response
actionPath - action path, as defined in configuration xml file
Returns:
resulting forward String, or ACTION_NOT_FOUND if not founded
Throws:
java.io.IOException
javax.servlet.ServletException
See Also:
doRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)


Jodd v0.24.5 Javadoc