Class Action

Action
Direct Known Subclasses:
DispatchAction, ForwardAction

public class Action

An Action is an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request. The controller (ActionServer) will select an appropriate Action for each request, create an instance (if necessary), and call the perform method.

When an Action instance is first created, the ActionServer controller will call $this->setActionServer() with an ActionServer parameter referencing the ActionServer controller instance to which this Action is attached. When the ActionServer controller is to be shut down (or restarted), the $this->setActionServer() method will be called with a NULL argument, which can be used to clean up any allocated resources in use by this Action.

Version:
2003
Author:
John C Wildenauer (php.MVC port)
Credits:
Craig R. McClanahan (Tomcat/catalina class: see jakarta.apache.org)

Field Summary
private  ActionServer $actionServer
          The ActionServer controller to which we are attached.
private  Locale $defaultLocale
          The system default Locale.
 
Constructor Summary
Action()
           
 
Method Summary
 ActionForward execute(var $mapping, var $form, var $request, var $response)
          Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it), with provision for handling exceptions thrown by the business logic.
 ActionServer getActionServer()
          Return the ActionServer controller instance to which we are attached.
 string getKey(var $key)
          The context attributes key under which our ActionServer instance will be stored.
 void saveErrors(var $request, var $errors)
          Save the specified error messages keys into the appropriate request attribute for use by the <phpmvc:errors> handler, if any messages are required.
 void setActionServer(var $actionServer)
          Set the ActionServer controller instance to which we are attached (if actionServer is non-null), or release any allocated resources (if actionServer is NULL).
 

Field Detail

$defaultLocale

private Locale $defaultLocale
The system default Locale. [protected static]

$actionServer

private ActionServer $actionServer
The ActionServer controller to which we are attached. [protected]
Constructor Detail

Action

public Action()
Method Detail

getKey

public string getKey(var $key)
The context attributes key under which our ActionServer instance will be stored.
Parameters:
string -  

getActionServer

public ActionServer getActionServer()
Return the ActionServer controller instance to which we are attached.

setActionServer

public void setActionServer(var $actionServer)
Set the ActionServer controller instance to which we are attached (if actionServer is non-null), or release any allocated resources (if actionServer is NULL).
Parameters:
ActionServer - The new ActionServer controller, if any
$actionServer - is passed by reference

execute

public ActionForward execute(var $mapping,
                             var $form,
                             var $request,
                             var $response)
Process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it), with provision for handling exceptions thrown by the business logic. Override this method in an extended Action class (eg: LoginAction) to define business class logic. This method is called from RequestProcessor to process an HTTP or HTTPS request.
Parameters:
ActionMapping - The ActionMapping used to select this instance
ActionForm - The optional ActionForm bean for this request (if any)
ServletRequest - The non-HTTP request we are processing
ServletResponse - The non-HTTP response we are creating

saveErrors

public void saveErrors(var $request,
                       var $errors)
Save the specified error messages keys into the appropriate request attribute for use by the <phpmvc:errors> handler, if any messages are required. Otherwise, ensure that the request attribute is not created.
Parameters:
HttpServletRequest - The servlet request we are processing
ActionErrors - Error messages object
$request - is passed by reference