org.davesag.generica.servlet.action
Class AbstractAction

java.lang.Object
  extended byorg.apache.struts.action.Action
      extended byorg.davesag.generica.servlet.action.AbstractAction
Direct Known Subclasses:
ChooseHomepageAction, DeleteTargetAction, ForwardAction, HandlePasswordHelperAction, HandleRegisterAction, HandleUpdateAction, InstantiationAction, ListAction, LoadCurrentUserAction, LoadTargetAction, LoginAction, LogoutAction, TargetAction

public abstract class AbstractAction
extends Action

An abstract Action that any of your actions should extend.

Since:
Generica 1.0
Version:
CVS Revision $Id: AbstractAction.java,v 1.28 2004/04/06 15:40:41 davesag Exp $
Author:
Dave Sag http://www.davesag.com

Field Summary
 
Fields inherited from class org.apache.struts.action.Action
ACTION_SERVLET_KEY, APPLICATION_KEY, DATA_SOURCE_KEY, defaultLocale, ERROR_KEY, EXCEPTION_KEY, FORM_BEANS_KEY, FORWARDS_KEY, LOCALE_KEY, MAPPING_KEY, MAPPINGS_KEY, MESSAGE_KEY, MESSAGES_KEY, MULTIPART_KEY, PLUG_INS_KEY, REQUEST_PROCESSOR_KEY, servlet, SERVLET_KEY, TRANSACTION_TOKEN_KEY
 
Constructor Summary
AbstractAction()
           
 
Method Summary
 void abortTransaction(Transaction tx)
          Aborts the supplied Transaction.
 void commitTransaction(Transaction tx)
          Commits the supplied Transaction.
protected  void furtherActions(Map params, HttpServletRequest request, HttpServletResponse response, ActionForm form)
          Perform any additional acts needed to fulfil the goals of your action.
 void genericActions(Map params, HttpServletRequest request, HttpServletResponse response, ActionForm form)
          Once the action's core controller's are used, look for any generic Actor or Presenter controllers and their parameters, and call them in the order we find them.
 ServletContext getApplication(HttpSession session)
          Returns the ServletContext.
 ActionController getController(String controllerclass)
          Gets the ActionController to be used by this action.
 ActionController getController(String controllerclass, HttpServletRequest request, HttpServletResponse response, ActionForm form)
          Gets the ActionController to be used by this action.
 Session getHibernateSession(HttpSession session)
          Returns the current hibernate session.
 Locale getLocale(HttpSession session)
          Returns the current active Locale
 MessageResources getMessages(HttpServletRequest request)
          Exposes the MessageResources to the Controllers .
 String getNextForward(HttpServletRequest request)
          What the next 'success' action should be.
 Transaction openTransaction(HttpSession session)
          Opens a transaction using the HibernateSession for the HttpSession provided.
protected  void presentation(Map params, HttpServletRequest request, HttpServletResponse response, ActionForm form)
          Prepare any additional presentation data needed by the GUI using any Presenter s derived from the Map of params supplied.
protected  void saveActionErrors(HttpServletRequest request, ActionErrors errors)
          The saveActionErrors method differs from the Action superclass' saveErrors method in that it also writes a "true" value to the Constants.ACTION_ERRORS key in the current request.
 void setNextForward(HttpServletRequest request, String forward)
          Tells the action what the next 'success' action should be.
 
Methods inherited from class org.apache.struts.action.Action
execute, execute, generateToken, getDataSource, getDataSource, getLocale, getResources, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, perform, perform, resetToken, saveErrors, saveMessages, saveToken, setLocale, setServlet, toHex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAction

public AbstractAction()
Method Detail

getController

public ActionController getController(String controllerclass)
                               throws ClassNotFoundException
Gets the ActionController to be used by this action.

Parameters:
controllerclass - The fully qualified class name of the ActionController.
Returns:
The ActionController implemetation.
Throws:
ClassNotFoundException - if the controllerclass can not be instantiated.

getController

public ActionController getController(String controllerclass,
                                      HttpServletRequest request,
                                      HttpServletResponse response,
                                      ActionForm form)
                               throws ClassNotFoundException
Gets the ActionController to be used by this action.

Parameters:
controllerclass - The fully qualified class name of the controller.
request - The Servlet Request.
response - the http response.
form - The Struts Action Form.
Returns:
The Controller.
Throws:
ClassNotFoundException - if the controllerclass can not be instantiated.

saveActionErrors

protected void saveActionErrors(HttpServletRequest request,
                                ActionErrors errors)
The saveActionErrors method differs from the Action superclass' saveErrors method in that it also writes a "true" value to the Constants.ACTION_ERRORS key in the current request.

Parameters:
request - The servlet request.
errors - the ActionErrors to save.

setNextForward

public void setNextForward(HttpServletRequest request,
                           String forward)
Tells the action what the next 'success' action should be. at the start of each generica action we set the nextForward to "success" but your Actor controllers may change that to suit themselves.

Parameters:
request - The request.
forward - The forward name.

getNextForward

public String getNextForward(HttpServletRequest request)
What the next 'success' action should be. at the start of each generica action we set the nextForward to "success" but your Actor controllers may change that to suit themselves.

Parameters:
request - The request.
Returns:
The forward name.

getApplication

public ServletContext getApplication(HttpSession session)
Returns the ServletContext.

Parameters:
session - the http session.
Returns:
The Web Application itself.

getMessages

public MessageResources getMessages(HttpServletRequest request)
Exposes the MessageResources to the Controllers . Normally the getResources method is protected and thus the Controllers can not get to it.

Parameters:
request - The HttpServletRequest.
Returns:
The Web Application's message resources.

getHibernateSession

public Session getHibernateSession(HttpSession session)
                            throws HibernateException
Returns the current hibernate session.

Parameters:
session - The current HttpSession.
Returns:
The current active hibernate session.
Throws:
HibernateException - if the Underlying SessionFactory could not be found. This usually means that the PersistenceManagementFilter has not been correctly configured in the web.xml file.
See Also:
PersistenceManagementFilter

openTransaction

public Transaction openTransaction(HttpSession session)
Opens a transaction using the HibernateSession for the HttpSession provided.

Parameters:
session - The HttpSession holding the active Hibernate SessionFactory.
Returns:
the transaction, or null if one could not be opened.

commitTransaction

public void commitTransaction(Transaction tx)
Commits the supplied Transaction.

Parameters:
tx - The Transaction to commit.

abortTransaction

public void abortTransaction(Transaction tx)
Aborts the supplied Transaction.

Parameters:
tx - The Transaction to commit.

getLocale

public Locale getLocale(HttpSession session)
                 throws Exception
Returns the current active Locale

Parameters:
session - the http session.
Returns:
The current active locale.
Throws:
Exception - if anything went wrong.

furtherActions

protected void furtherActions(Map params,
                              HttpServletRequest request,
                              HttpServletResponse response,
                              ActionForm form)
Perform any additional acts needed to fulfil the goals of your action.

The actor controllers all take the same set of actor-params so you can link actor and presentation controllers using common param names or values.

Parameters:
params - A map of the Controller class names defined in struts-config.xml for this action.
request - The incoming HttpRequest.
response - the http response.
form - The ActionForm if any.
See Also:
Actor

presentation

protected void presentation(Map params,
                            HttpServletRequest request,
                            HttpServletResponse response,
                            ActionForm form)
Prepare any additional presentation data needed by the GUI using any Presenter s derived from the Map of params supplied. Call this method in your action immediately prior to the end of the execute method.

The presentation controllers all take the same set of presentation-params so you can link controllers using common presentation param names or values.

Parameters:
params - A map of the Controller class names defined in struts-config.xml for this action.
request - The incoming HttpRequest.
response - the http response.
form - The ActionForm if any.
See Also:
Presenter

genericActions

public void genericActions(Map params,
                           HttpServletRequest request,
                           HttpServletResponse response,
                           ActionForm form)
Once the action's core controller's are used, look for any generic Actor or Presenter controllers and their parameters, and call them in the order we find them.

Parameters:
params - A map of the Controller class names defined in struts-config.xml for this action.
request - The incoming HttpRequest.
response - the http response.
form - The ActionForm if any.
See Also:
Presenter, Actor


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.