com.ivata.mask.web.struts
Class MaskAction

java.lang.Object
  extended byorg.apache.struts.action.Action
      extended bycom.ivata.mask.web.struts.MaskAction
Direct Known Subclasses:
FindAction, InputMaskAction, ListAction, NewAction

public abstract class MaskAction
extends org.apache.struts.action.Action

Every Action in the system derives from this class, making it possible to centralize logging instantiation, and check we have a valid intranet session.

Since:
ivata masks 0.4 (2002-11-10)
Version:
$Revision: 1.12 $
Author:
Colin MacLeod colin.macleod@ivata.com

Field Summary
 
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 
Constructor Summary
MaskAction(com.ivata.mask.MaskFactory maskFactoryParam, MaskAuthenticator authenticatorParam)
           Construct a mask action, with the given authenticator.
 
Method Summary
 void clear(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionErrors errors, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session)
           Called when the clear button is pressed, or after an ok or delete button, where the session should be restored to its default state.
 java.lang.String execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionErrors errors, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session)
           Called from the other execute method, this can be overridden by each subclass to provide the ivata -specific processing required.
 org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           Generic method called by the Struts interface.
protected  MaskAuthenticator getAuthenticator()
           This mask authenticator will be used to confirm whether or not the user should be allowed to continue.
protected  java.lang.String getFromRequestOrForm(java.lang.String name, javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionForm form)
           Helper method to see if the parameter with the given name is set in the request and, if not, if it is set in the form provided.
protected  java.lang.String getFromRequestOrForm(java.lang.String name, javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionForm form, java.lang.String defaultValue)
           Helper method to see if the parameter with the given name is set in the request and, if not, if it is set in the form provided.
protected  java.lang.String getInputMask(javax.servlet.http.HttpServletRequest request, java.lang.Object form)
           This method ascertains the correct input mask to use.
protected  java.lang.String getListMask(javax.servlet.http.HttpServletRequest request, java.lang.Object form)
           This method ascertains the correct list mask to use.
protected  com.ivata.mask.MaskFactory getMaskFactory()
           This factory is needed to access the masks and groups of masks.
protected  boolean isCancelled(javax.servlet.http.HttpServletRequest request)
          Not sure why I needed to override this! Refer to Action.isCancelled(javax.servlet.http.HttpServletRequest).
 java.lang.String onConfirm(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionErrors errors, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, java.lang.String defaultForward)
           This method is called if the ok or apply buttons are pressed.
 java.lang.String onDelete(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionErrors errors, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpSession session, java.lang.String defaultForward)
           This method is called if the delete (confirm, not warn) button is pressed.
 void setLogin(boolean loginParam)
           Set to true by LoginAction to indicate the user name should not be checked.
 
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MaskAction

public MaskAction(com.ivata.mask.MaskFactory maskFactoryParam,
                  MaskAuthenticator authenticatorParam)

Construct a mask action, with the given authenticator.

Parameters:
maskFactoryParam - This factory is needed to access the masks and groups of masks.
authenticatorParam - used to confirm whether or not the user should be allowed to continue, in the execute method.
Method Detail

clear

public void clear(org.apache.struts.action.ActionMapping mapping,
                  org.apache.struts.action.ActionErrors errors,
                  org.apache.struts.action.ActionForm form,
                  javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response,
                  javax.servlet.http.HttpSession session)
           throws com.ivata.mask.util.SystemException

Called when the clear button is pressed, or after an ok or delete button, where the session should be restored to its default state.

Parameters:
mapping - The ActionMapping used to select this instance.
errors - valid errors object to append errors to. If there are any errors, the action will return to the input.
form - optional ActionForm bean for this request (if any)
request - non-HTTP request we are processing
response - The non-HTTP response we are creating
session - returned from the request parameter.
Throws:
com.ivata.mask.util.SystemException - if there is any problem which prevents processing. It will result in the webapp being forwarded to the standard error page.

execute

public java.lang.String execute(org.apache.struts.action.ActionMapping mapping,
                                org.apache.struts.action.ActionErrors errors,
                                org.apache.struts.action.ActionForm form,
                                javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response,
                                javax.servlet.http.HttpSession session)
                         throws com.ivata.mask.util.SystemException

Called from the other execute method, this can be overridden by each subclass to provide the ivata -specific processing required.

Parameters:
mapping - The ActionMapping used to select this instance.
errors - valid errors object to append errors to. If there are any errors, the action will return to the input.
form - optional ActionForm bean for this request (if any)
request - non-HTTP request we are processing
response - The non-HTTP response we are creating
session - returned from the request parameter.
Returns:
this method returns the string used to identify the correct Struts ActionForward which should follow this page, or null if it should return to the input.
Throws:
com.ivata.mask.util.SystemException - if there is any problem which prevents processing. It will result in the webapp being forwarded to the standard error page.

execute

public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
                                                      org.apache.struts.action.ActionForm form,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response)
                                               throws java.lang.Exception

Generic method called by the Struts interface.

Process the specified HTTP request, and create the corresponding HTTP response. Return an ActionForwardinstance describing where and how control should be forwarded, or null if the response has already been completed.

Parameters:
mapping - The ActionMapping used to select this instance
form - The optional ActionForm bean for this request (if any)
request - The non-HTTP request we are processing
response - The non-HTTP response we are creating
Returns:
this method returns a "success" ActionForward if the compose session is cancelled or successfully sent, otherwise a "failure" ActionForward.
Throws:
java.lang.Exception - if the application business logic throws an exception

getAuthenticator

protected MaskAuthenticator getAuthenticator()

This mask authenticator will be used to confirm whether or not the user should be allowed to continue.

Returns:
Returns the authenticator.

getFromRequestOrForm

protected final java.lang.String getFromRequestOrForm(java.lang.String name,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      org.apache.struts.action.ActionForm form)
                                               throws com.ivata.mask.util.SystemException

Helper method to see if the parameter with the given name is set in the request and, if not, if it is set in the form provided.

Parameters:
name - the name of the parameter to look for.
request - servlet request to look for the parameter in.
form - the form to search for the parameter, if it is not found in the request.
Returns:
value from the request parameter with the name given. If that is null, then the value of the form attribute is returned, or null if there is no parameter or form attribute with the given name.
Throws:
com.ivata.mask.util.SystemException - if there is an InvocationTargetException or an IllegalAccessException accessing the parameter.

getFromRequestOrForm

protected final java.lang.String getFromRequestOrForm(java.lang.String name,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      org.apache.struts.action.ActionForm form,
                                                      java.lang.String defaultValue)
                                               throws com.ivata.mask.util.SystemException

Helper method to see if the parameter with the given name is set in the request and, if not, if it is set in the form provided.

Parameters:
name - the name of the parameter to look for.
request - servlet request to look for the parameter in.
form - the form to search for the parameter, if it is not found in the request.
Returns:
value from the request parameter with the name given. If that is null, then the value of the form attribute is returned, or defaultValue if there is no parameter or form attribute with the given name.
Throws:
com.ivata.mask.util.SystemException - if there is an InvocationTargetException or an IllegalAccessException accessing the parameter.

getInputMask

protected final java.lang.String getInputMask(javax.servlet.http.HttpServletRequest request,
                                              java.lang.Object form)
                                       throws com.ivata.mask.util.SystemException

This method ascertains the correct input mask to use. First it looks for an override in the request, then it looks for a parameter in the current form before finally using the default.

Parameters:
request - servlet request we are processing. A request parameter will be first checked here.
form - the form currently being processed. If there is no request parameter, the property "inputMask" is read from the form.
Returns:
string representing the action to perform for the current input mask.
Throws:
com.ivata.mask.util.SystemException - if the input mask cannot be retrieved.

getListMask

protected final java.lang.String getListMask(javax.servlet.http.HttpServletRequest request,
                                             java.lang.Object form)
                                      throws com.ivata.mask.util.SystemException

This method ascertains the correct list mask to use. First it looks for an override in the request, then it looks for a parameter in the current form before finally using the default.

Parameters:
request - servlet request we are processing. A request parameter will be first checked here.
form - the form currently being processed. If there is no request parameter, the property "listMask" is read from the form.
Returns:
string representing the action to perform for the current list mask.
Throws:
com.ivata.mask.util.SystemException - if the list mask cannot be retrieved.

getMaskFactory

protected com.ivata.mask.MaskFactory getMaskFactory()

This factory is needed to access the masks and groups of masks.

Returns:
Returns the maskFactory, used to access masks and groups of masks.

isCancelled

protected final boolean isCancelled(javax.servlet.http.HttpServletRequest request)
Not sure why I needed to override this! Refer to Action.isCancelled(javax.servlet.http.HttpServletRequest).

Parameters:
request - Refer to Action.isCancelled(javax.servlet.http.HttpServletRequest).
Returns:
Refer to Action.isCancelled(javax.servlet.http.HttpServletRequest).
See Also:
Action.isCancelled(javax.servlet.http.HttpServletRequest)

onConfirm

public java.lang.String onConfirm(org.apache.struts.action.ActionMapping mapping,
                                  org.apache.struts.action.ActionErrors errors,
                                  org.apache.struts.action.ActionForm form,
                                  javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response,
                                  javax.servlet.http.HttpSession session,
                                  java.lang.String defaultForward)
                           throws com.ivata.mask.util.SystemException

This method is called if the ok or apply buttons are pressed.

Parameters:
mapping - The ActionMapping used to select this instance.
errors - valid errors object to append errors to. If there are any errors, the action will return to the input.
form - optional ActionForm bean for this request (if any)
request - non-HTTP request we are processing
response - The non-HTTP response we are creating
session - returned from the request parameter.
defaultForward - "ok" if the Ok button was pressed, otherwise "apply" if the Apply button was pressed.
Returns:
this method returns the string used to identify the correct Struts ActionForward which should follow this page, or null if it should return to the input.
Throws:
com.ivata.mask.util.SystemException - if there is any problem which prevents processing. It will result in the webapp being forwarded to the standard error page.

onDelete

public java.lang.String onDelete(org.apache.struts.action.ActionMapping mapping,
                                 org.apache.struts.action.ActionErrors errors,
                                 org.apache.struts.action.ActionForm form,
                                 javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 javax.servlet.http.HttpSession session,
                                 java.lang.String defaultForward)
                          throws com.ivata.mask.util.SystemException

This method is called if the delete (confirm, not warn) button is pressed.

Parameters:
mapping - The ActionMapping used to select this instance.
errors - valid errors object to append errors to. If there are any errors, the action will return to the input.
form - optional ActionForm bean for this request (if any)
request - non-HTTP request we are processing
response - The non-HTTP response we are creating
session - returned from the request parameter.
defaultForward - usually "delete". This is the forward it is suggested you use, if everything is ok.
Returns:
this method returns the string used to identify the correct Struts ActionForward which should follow this page, or null if it should return to the input.
Throws:
com.ivata.mask.util.SystemException - if there is any problem which prevents processing. It will result in the webapp being forwarded to the standard error page.

setLogin

public final void setLogin(boolean loginParam)

Set to true by LoginAction to indicate the user name should not be checked.

Parameters:
loginParam - the new value of login.


Copyright © 2001-2005 ivata limited. All Rights Reserved.