org.jaffa.presentation.portlet
Class ActionBase

java.lang.Object
  extended byorg.apache.struts.action.Action
      extended byorg.jaffa.presentation.portlet.ActionBase
Direct Known Subclasses:
ComponentDetailsAction, ComponentExplorerAction, FinderAction, MaintAction, SessionExplorerAction, StartComponentAction

public class ActionBase
extends Action

This is the base class for all 'Action' classes


Field Summary
protected  Component component
          The optional component for this request (if any)
protected  ActionForm form
          The optional ActionForm bean for this request (if any)
protected  ActionMapping mapping
          The ActionMapping used to select this instance
protected  HttpServletRequest request
          The HTTP request we are processing
protected  HttpServletResponse response
          The HTTP response we are creating
 
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
ActionBase()
           
 
Method Summary
protected  FormKey defaultAction()
          The default action method which should be overriden by the extending class.
protected  FormKey determineCurrentFormKey(FormBase formBase)
          Determines the currentFormKey, if possible, utilising the NAME field (if defined) and the componentId of the formBase.
 FormKey do_HistoryNav_Clicked(String index)
          This is the handler for the event generated in the historyNav for rendering a previous screen.
 FormKey do_refresh()
          Determines the currentFormKey, if possible, utilising the NAME field (if defined) and the componentId of the formBase.
 ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
          Check the eventId & invoke the suitable method which will return the FormKey.
protected  FormKey executeEvent(String eventId)
          This method will introspect this class for a suitable handler for the input eventId and invoke it.
protected  ActionForward handleNullFormKey()
          This is invoked whenever a null FormKey is returned by an event handler.
protected  boolean isTokenValid(HttpServletRequest request)
          Return true if there is a transaction token stored in the component, and the value submitted as a request parameter with this action matches it.
protected  boolean isTokenValid(HttpServletRequest request, boolean reset)
          Return true if there is a transaction token stored in the component, and the value submitted as a request parameter with this action matches it.
protected  String parseFormName(String formName)
          This will parse the input FormName for parameters and set them as attributes on the request stream.
protected  void performTokenValidation(HttpServletRequest request)
          This merely invokes the isTokenValid() method and throws the ApplicationExceptions if the validation fails.
protected  FormKey processContainerFormKey(FormKey fk)
          Returns the ContainerFormKey, if the component specified by the input FormKey has one defined.
protected  void resetToken(HttpServletRequest request)
          Reset the saved transaction token in the component.
protected  void saveToken(FormKey fk)
          Save a new transaction token in the component.
 
Methods inherited from class org.apache.struts.action.Action
execute, generateToken, getDataSource, getDataSource, getLocale, getResources, getResources, getResources, getServlet, isCancelled, perform, perform, saveErrors, saveMessages, saveToken, setLocale, setServlet, toHex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapping

protected ActionMapping mapping
The ActionMapping used to select this instance


form

protected ActionForm form
The optional ActionForm bean for this request (if any)


request

protected HttpServletRequest request
The HTTP request we are processing


response

protected HttpServletResponse response
The HTTP response we are creating


component

protected Component component
The optional component for this request (if any)

Constructor Detail

ActionBase

public ActionBase()
Method Detail

execute

public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
                      throws Exception
Check the eventId & invoke the suitable method which will return the FormKey. It will invoke the defaultAction() method in case the eventId is null. This will throw the EventHandlerMissingRuntimeException in case no method is found.

Parameters:
mapping - The ActionMapping used to select this instance
form - The optional ActionForm bean for this request (if any)
request - The HTTP request we are processing
response - The HTTP response we are creating
Returns:
An ActionForward instance describing where and how control should be forwarded, or null if the response has already been completed
Throws:
Exception - if the application business logic throws an exception

defaultAction

protected FormKey defaultAction()
                         throws Exception
The default action method which should be overriden by the extending class. This method is invoked by the perform() method, if no eventId is passed. If the extending class doesn't provide an implementation of this method, a EventHandlerMissingRuntimeException will be thrown. If all the 'submit' actions send an eventId, then there is no need to provide any implementation for this method.

Returns:
A FormKey instance which describes the current Component & Form
Throws:
Exception - if the application business logic throws an exception

saveToken

protected void saveToken(FormKey fk)
Save a new transaction token in the component.

Parameters:
fk - The FormKey from which the component will be determined.

isTokenValid

protected boolean isTokenValid(HttpServletRequest request)
Return true if there is a transaction token stored in the component, and the value submitted as a request parameter with this action matches it. Else it returns false.

Parameters:
request - The servlet request we are processing
Returns:
true if there is a transaction token stored in the component, and the value submitted as a request parameter with this action matches it. Else it returns false.

isTokenValid

protected boolean isTokenValid(HttpServletRequest request,
                               boolean reset)
Return true if there is a transaction token stored in the component, and the value submitted as a request parameter with this action matches it. Else it returns false.

Parameters:
request - The servlet request we are processing
reset - Should we reset the token after checking it?
Returns:
true if there is a transaction token stored in the component, and the value submitted as a request parameter with this action matches it. Else it returns false.

resetToken

protected void resetToken(HttpServletRequest request)
Reset the saved transaction token in the component. This indicates that transactional token checking will not be needed on the next request that is submitted.

Parameters:
request - The servlet request we are processing

performTokenValidation

protected void performTokenValidation(HttpServletRequest request)
                               throws ApplicationExceptions
This merely invokes the isTokenValid() method and throws the ApplicationExceptions if the validation fails.

Parameters:
request - The servlet request we are processing
Throws:
ApplicationExceptions - if the token on the component does not match the token submitted as the request paramter.

do_refresh

public FormKey do_refresh()
Determines the currentFormKey, if possible, utilising the NAME field (if defined) and the componentId of the formBase. This event is invoked when a user changes the settings of the UserGrid in a screen.

Returns:
The FormKey for the Results screen.

do_HistoryNav_Clicked

public FormKey do_HistoryNav_Clicked(String index)
This is the handler for the event generated in the historyNav for rendering a previous screen.

Parameters:
index - The index for the screen to be rendered. The most ancient screen(usually the Home) will be indexed '0'
Returns:
The FormKey for a previous screen.

executeEvent

protected FormKey executeEvent(String eventId)
                        throws Exception
This method will introspect this class for a suitable handler for the input eventId and invoke it.

Parameters:
eventId - The event.
Returns:
The output from the input handler.
Throws:
Exception - If any error occurs in introspection or invocation of the event-handler.

handleNullFormKey

protected ActionForward handleNullFormKey()
                                   throws Exception
This is invoked whenever a null FormKey is returned by an event handler. This will kill the UserSession, if the config property 'PROP_SECURITY_PORTLET_INVALIDATE_SESSION_BEFORE_REDIRECTING_TO_FINAL_URL' is set to true. It will then redirect to the root of this webapp '/'.

Returns:
The ActionForward representing the redirection to the root of this webapp '/'.
Throws:
Exception - if any error occurs.

determineCurrentFormKey

protected FormKey determineCurrentFormKey(FormBase formBase)
Determines the currentFormKey, if possible, utilising the NAME field (if defined) and the componentId of the formBase.

Parameters:
formBase - The input FormBean from which the current FormKey is to be determined.
Returns:
The current FormKey.

parseFormName

protected String parseFormName(String formName)
                        throws UnsupportedEncodingException
This will parse the input FormName for parameters and set them as attributes on the request stream. It will then return the FormName minus the parameters.

Parameters:
formName - The input FormName.
Returns:
The FormName minus the parameters, if any.
Throws:
UnsupportedEncodingException - This will be thrown if the JVM doesn't support the 'UTF-8' encoding. Highly unlikely that this will be thrown.

processContainerFormKey

protected FormKey processContainerFormKey(FormKey fk)
Returns the ContainerFormKey, if the component specified by the input FormKey has one defined. For such a component a FormKeyChangeEvent will be sent to the registered FormKeyChangeListeners.

Parameters:
fk - The input FormKey.
Returns:
The ContainerFormKey, if exists, or just the input FormKey.


Copyright © 2002-2004 JAFFA Project.