PAJES 3.0.21

org.pajes.db.entity
Class MaintenanceServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.pajes.servlet.PajeServlet
              extended by org.pajes.servlet.DataAccessPajeServlet
                  extended by org.pajes.servlet.AuthenticatedPajeServlet
                      extended by org.pajes.db.entity.MaintenanceServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public abstract class MaintenanceServlet
extends AuthenticatedPajeServlet

Servlet to manage Entity objects. Access to this servlet can be controlled by the use of the ROLE_ATTRIBUTE, which is a ServletContext attribute to set the name of the role that may access sub-classes of this class. If not specified in the deployment descriptor, any role may invoke MaintenanceServlet sub-classes.

Actions may also be audited through the use of the AUDIT_ATTRIBUTE ServletContext attribute. If this attribute exists, it will be checked to see if it contains the current ACTION_PARAMETERvalue. Mulitple types of actions can be audited by concatenating the required action values. Audit messages are written to the ServletContext log.

See Also:
Serialized Form

Field Summary
static java.lang.String ACTION_PARAMETER
          The name of the request parameter that determines what action will be taken by this servlet.
static java.lang.String AUDIT_ATTRIBUTE
          Context attribute to set the ACTION_PARAMETERvalues that will be audited.
static java.lang.String CANCEL_ACTION_VALUE
          The value of the ACTION_PARAMETERthat indicates that the request is to cancel changes to an Entity and return to the list.
static java.lang.String CREATE_ACTION_VALUE
          The value of the ACTION_PARAMETERthat indicates that the request is to create a new Entity.
static java.lang.String DELETE_ACTION_VALUE
          The value of the ACTION_PARAMETERthat indicates that the request is to delete an Entity.
static java.lang.String MODIFY_ACTION_VALUE
          The value of the ACTION_PARAMETERthat indicates that the request is to edit an existing Entity.
static java.lang.String ROLE_ATTRIBUTE
          Context attribute to set the name of the role that may access sub-classes of this class.
static java.lang.String UPDATE_ACTION_VALUE
          The value of the ACTION_PARAMETERthat indicates that the request is to update an existing Entity.
static java.lang.String VIEW_ACTION_VALUE
          The value of the ACTION_PARAMETERthat indicates that the request is to view an existing Entity.
 
Constructor Summary
protected MaintenanceServlet(Manager manager)
          Creates a servlet that will manage Entities.
 
Method Summary
protected  void audit(javax.servlet.http.HttpServletRequest request, java.lang.String action, Entity entity)
          Handles auditing of requests.
protected  void beforeSave(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Entity entity)
          Called by doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), before saving the Entity.
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles the request to display a screen.
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles an action request.
protected  Paje getCancelDocument(javax.servlet.http.HttpServletRequest request)
          Returns the document that will be sent back to the browser when the user selected the cancelaction.
protected  Paje getEditor(javax.servlet.http.HttpServletRequest request, boolean isNew)
          Returns a Paje to display and/or edit an Entity object.
protected  Entity getEntityFromSession(javax.servlet.http.HttpServletRequest request)
          Retrieves the Entity from the HttpSession that matches the key contained in the request parameters.
protected static Entity getEntityFromSession(Manager manager, javax.servlet.http.HttpServletRequest request)
          Retrieves the Entity from the HttpSession that matches the key contained in the request parameters.
protected  Paje getErrorDocument(javax.servlet.http.HttpServletRequest request, java.lang.String message)
          Creates a document that contains the user input and an error message.
protected  Paje getExceptionDocument(javax.servlet.http.HttpServletRequest request, java.lang.Exception exception)
          Returns the document that will be sent back to the browser when an Exception is caught when retrieving or saving an Entity.
protected  Paje getLister(javax.servlet.http.HttpServletRequest request)
          Returns a Paje to display a list of Entity objects.
protected  Manager getManager()
          Returns the Managerof the Entityobjects administered by this servlet.
protected  Paje getNoRowsAffectedDocument(javax.servlet.http.HttpServletRequest request)
          Returns the document that will be sent back to the browser when no rows are affected when it is attempted to save the Entity to the database.
protected  Paje getSQLExceptionDocument(javax.servlet.http.HttpServletRequest request, java.sql.SQLException exception)
          Returns the document that will be sent back to the browser when a SQLException is caught when retrieving or saving an Entity.
protected  Paje getSuccessDocument(javax.servlet.http.HttpServletRequest request)
          Returns the document that will be sent back to the browser when a no exceptions were caught when retrieving or saving an Entity.
protected  Paje getViewer(javax.servlet.http.HttpServletRequest request)
          Returns a Paje to display an Entity object.
protected  void handleCancel(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Deprecated. 2.3.3: Use handleCancel(HttpServletRequest request, HttpServletResponse response, Entity entity) instead.
protected  void handleCancel(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Entity entity)
          Handles the situation where the user selects the cancel action.
protected  void handleException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Exception exception, Entity entity)
          Handles the situation where a Exception is caught when retrieving or saving an Entity.
protected  void handleNoRowsAffected(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Entity entity)
          Handles the situation where no rows are affected when it is attempted to save the Entity to the database.
protected  void handleSQLException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.sql.SQLException exception, Entity entity)
          Handles the situation where a SQLException is caught when retrieving or saving an Entity.
protected  void handleSuccess(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int rows, Entity entity)
          Handles the situation where a delete, update or insert succeeded.
 void init(javax.servlet.ServletConfig config)
          Initialises this maintenance servlet.
protected  boolean isCancelAction(java.lang.String action)
          Determines if this is a request to cancel making changes to an entity.
protected  boolean isDeleteAction(java.lang.String action)
          Determines if this is a request to delete an entity.
protected  boolean isPermitted(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Validates access to this servlet.
protected  boolean isUpdateAction(java.lang.String action)
          Determines if this is a request to save a modified or new entity.
protected  void onCreate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Paje doc)
          Called by doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), when a CREATE_ACTION_VALUErequest is received, after creating the document to be returned to the browser.
protected  void onList(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Paje lister)
          Called by doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), when neither the CREATE_ACTION_VALUE, VIEW_ACTION_VALUEor MODIFY_ACTION_VALUEactions are specifed on the request, after creating the lister document to be returned to the browser.
protected  void onModify(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Paje doc)
          Called by doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), when a MODIFY_ACTION_VALUErequest is received, after creating the document to be returned to the browser.
protected  void onView(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Paje doc)
          Called by doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), when a VIEW_ACTION_VALUErequest is received, after creating the document to be returned to the browser.
protected  void removeEntityFromSession(javax.servlet.http.HttpServletRequest request, Entity entity)
          Removes the specified Entity from the HttpSession.
protected  Entity retrieveEntityBeforeUpdate(Entity entity, Scope scope, boolean create)
          Retrieves the entity before applying the update.
 
Methods inherited from class org.pajes.servlet.AuthenticatedPajeServlet
doForbidden, getAccessPermission, isPermitted, service
 
Methods inherited from class org.pajes.servlet.DataAccessPajeServlet
getDBConnection, getDBConnection, getDBConnectionPoolManager
 
Methods inherited from class org.pajes.servlet.PajeServlet
createPaje, createPaje, createPaje, getAbsoluteHREF, getBaseHREF, getMaxFileUploadSize, getPajeFactory, getResource, getUploadedFile, getUploadedFileNames, handleException, log, log, setInputFieldsFromRequestAttributes, setInputFieldsFromRequestParameters, setMaxFileUploadSize, setPajeFactory
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_PARAMETER

public static final java.lang.String ACTION_PARAMETER
The name of the request parameter that determines what action will be taken by this servlet. The absence of this parameter on a GET request, or a value other than one of , MODIFY_ACTION_VALUEor , indicates that a list is required.

The value of this constant is "_a_".

See Also:
Constant Field Values

AUDIT_ATTRIBUTE

public static final java.lang.String AUDIT_ATTRIBUTE
Context attribute to set the ACTION_PARAMETERvalues that will be audited.

See Also:
Constant Field Values

CANCEL_ACTION_VALUE

public static final java.lang.String CANCEL_ACTION_VALUE
The value of the ACTION_PARAMETERthat indicates that the request is to cancel changes to an Entity and return to the list.

The value of this constant is "x".

See Also:
Constant Field Values

CREATE_ACTION_VALUE

public static final java.lang.String CREATE_ACTION_VALUE
The value of the ACTION_PARAMETERthat indicates that the request is to create a new Entity.

The value of this constant is "n".

See Also:
Constant Field Values

DELETE_ACTION_VALUE

public static final java.lang.String DELETE_ACTION_VALUE
The value of the ACTION_PARAMETERthat indicates that the request is to delete an Entity.

The value of this constant is "d".

See Also:
Constant Field Values

MODIFY_ACTION_VALUE

public static final java.lang.String MODIFY_ACTION_VALUE
The value of the ACTION_PARAMETERthat indicates that the request is to edit an existing Entity.

The value of this constant is "e".

See Also:
Constant Field Values

ROLE_ATTRIBUTE

public static final java.lang.String ROLE_ATTRIBUTE
Context attribute to set the name of the role that may access sub-classes of this class. If not specified in the deployment descriptor, any role may invoke MaintenanceServlet sub-classes.

See Also:
Constant Field Values

UPDATE_ACTION_VALUE

public static final java.lang.String UPDATE_ACTION_VALUE
The value of the ACTION_PARAMETERthat indicates that the request is to update an existing Entity.

The value of this constant is "u".

See Also:
Constant Field Values

VIEW_ACTION_VALUE

public static final java.lang.String VIEW_ACTION_VALUE
The value of the ACTION_PARAMETERthat indicates that the request is to view an existing Entity.

The value of this constant is "v".

See Also:
Constant Field Values
Constructor Detail

MaintenanceServlet

protected MaintenanceServlet(Manager manager)
Creates a servlet that will manage Entities.

Parameters:
manager - the Manager of the Entity objects to be administered.
Method Detail

getEntityFromSession

protected static Entity getEntityFromSession(Manager manager,
                                             javax.servlet.http.HttpServletRequest request)
Retrieves the Entity from the HttpSession that matches the key contained in the request parameters.

Parameters:
manager - the entity manager.
request - the servlet request.
Returns:
the Entity, or null if no matching Entity was found in the session.

init

public final void init(javax.servlet.ServletConfig config)
                throws javax.servlet.ServletException
Initialises this maintenance servlet.

Sub-classes should over-ride the init() method to perform any specific initialisation.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class PajeServlet
Parameters:
config - the ServletConfig object.
Throws:
javax.servlet.ServletException - if a fatal exception occurs.

audit

protected void audit(javax.servlet.http.HttpServletRequest request,
                     java.lang.String action,
                     Entity entity)
Handles auditing of requests.

Parameters:
request - the request objects.
action - the ACTION_PARAMETERvalue.
entity - the Entity being retrieved created, deleted or updated.

beforeSave

protected void beforeSave(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          Entity entity)
                   throws javax.servlet.ServletException,
                          java.io.IOException,
                          java.sql.SQLException
Called by doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), before saving the Entity. The default implementation does nothing.

Parameters:
request - the request object.
response - the response object.
entity - the Entity about to be saved.
Throws:
javax.servlet.ServletException - if a fatal exception occurs.
java.io.IOException - if an IO error occurs.
java.sql.SQLException - if an exception occurs when accessing the database.

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Handles the request to display a screen.

If the neither the CREATE_ACTION_VALUE, VIEW_ACTION_VALUE or MODIFY_ACTION_VALUEvalues are specified for the ACTION_PARAMETERrequest parameter}, the listerwill be displayed.

Overrides:
doGet in class PajeServlet
Parameters:
request - the request object.
response - the response object.
Throws:
javax.servlet.ServletException - if a fatal exception occurs.
java.io.IOException - if an IO error occurs.

doPost

protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException,
                      java.io.IOException
Handles an action request.

After handling the request, the user will be returned a document based on the outcome of the action they selected.

Overrides:
doPost in class PajeServlet
Parameters:
request - the request object.
response - the response object.
Throws:
javax.servlet.ServletException - if a fatal exception occurs.
java.io.IOException - if an IO error occurs.
See Also:
handleCancel(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), handleNoRowsAffected(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.pajes.db.entity.Entity), handleSQLException(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.sql.SQLException, org.pajes.db.entity.Entity), handleSuccess(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, int, org.pajes.db.entity.Entity)

getCancelDocument

protected Paje getCancelDocument(javax.servlet.http.HttpServletRequest request)
                          throws java.io.IOException
Returns the document that will be sent back to the browser when the user selected the cancelaction.

The default implementation returns the user to the lister.

Parameters:
request - the request object.
Returns:
the Paje object.
Throws:
java.io.IOException - if an IO error occurs.

getEditor

protected Paje getEditor(javax.servlet.http.HttpServletRequest request,
                         boolean isNew)
                  throws EntityException,
                         java.io.IOException
Returns a Paje to display and/or edit an Entity object. The default implementation returns the default editor.

Parameters:
request - the request object.
isNew - true if the edit form is to be returned empty so that a new Entity may be defined, or false if an Entity is to be retrieved based on the requestparameters, and then used to populate the form input fields.
Returns:
a new Paje object.
Throws:
EntityException - if an error occurs instantiating the Editor.
java.io.IOException - if an error occurs creating the Paje.
See Also:
DefaultEditor

getEntityFromSession

protected Entity getEntityFromSession(javax.servlet.http.HttpServletRequest request)
Retrieves the Entity from the HttpSession that matches the key contained in the request parameters.

Parameters:
request - the servlet request.
Returns:
the Entity, or null if no matching Entity was found in the session.

getLister

protected Paje getLister(javax.servlet.http.HttpServletRequest request)
                  throws EntityException,
                         java.io.IOException
Returns a Paje to display a list of Entity objects. The default implementation returns the default lister.

Parameters:
request - the request object.
Returns:
a new Paje object populated with the list of Entity objects.
Throws:
EntityException - if an error occurs instantiating the Lister.
java.io.IOException - if an error occurs creating the Paje.
See Also:
DefaultLister

getManager

protected Manager getManager()
Returns the Managerof the Entityobjects administered by this servlet.

Returns:
the Manager.

getNoRowsAffectedDocument

protected Paje getNoRowsAffectedDocument(javax.servlet.http.HttpServletRequest request)
                                  throws java.io.IOException
Returns the document that will be sent back to the browser when no rows are affected when it is attempted to save the Entity to the database.

Parameters:
request - the request object.
Returns:
the Paje object.
Throws:
java.io.IOException - if an IO error occurs.

getExceptionDocument

protected Paje getExceptionDocument(javax.servlet.http.HttpServletRequest request,
                                    java.lang.Exception exception)
                             throws java.io.IOException
Returns the document that will be sent back to the browser when an Exception is caught when retrieving or saving an Entity.

Parameters:
request - the request object.
exception - the Exception object.
Returns:
the Paje object.
Throws:
java.io.IOException - if an IO error occurs.

getSQLExceptionDocument

protected Paje getSQLExceptionDocument(javax.servlet.http.HttpServletRequest request,
                                       java.sql.SQLException exception)
                                throws java.io.IOException
Returns the document that will be sent back to the browser when a SQLException is caught when retrieving or saving an Entity.

Parameters:
request - the request object.
exception - the SQLException object.
Returns:
the Paje object.
Throws:
java.io.IOException - if an IO error occurs.

getSuccessDocument

protected Paje getSuccessDocument(javax.servlet.http.HttpServletRequest request)
                           throws java.io.IOException
Returns the document that will be sent back to the browser when a no exceptions were caught when retrieving or saving an Entity.

The default implementation calls getLister(javax.servlet.http.HttpServletRequest).

Parameters:
request - the request object.
Returns:
the Paje object.
Throws:
java.io.IOException - if an IO error occurs.

getViewer

protected Paje getViewer(javax.servlet.http.HttpServletRequest request)
                  throws EntityException,
                         java.io.IOException
Returns a Paje to display an Entity object. The default implementation returns the default viewer.

Parameters:
request - the request object.
Returns:
a new Paje object.
Throws:
EntityException - if an error occurs instantiating the Editor.
java.io.IOException - if an error occurs creating the Paje.
See Also:
DefaultEditor

handleCancel

@Deprecated
protected void handleCancel(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
                     throws java.io.IOException,
                            javax.servlet.ServletException
Deprecated. 2.3.3: Use handleCancel(HttpServletRequest request, HttpServletResponse response, Entity entity) instead.

Handles the situation where the user selects the cancel action.

This method has been deprecated. Use handleCancel(HttpServletRequest request, HttpServletResponse response, Entity entity) instead.

Parameters:
request - the request object.
response - the response object.
Throws:
java.io.IOException - if an IO error occurs.
javax.servlet.ServletException - if a fatal exception occurs.

handleCancel

protected void handleCancel(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            Entity entity)
                     throws java.io.IOException,
                            javax.servlet.ServletException
Handles the situation where the user selects the cancel action.

The default implementation returns the document from getCancelDocument(javax.servlet.http.HttpServletRequest) to the browser.

Parameters:
request - the request object.
response - the response object.
entity - the entity removed from the session.
Throws:
java.io.IOException - if an IO error occurs.
javax.servlet.ServletException - if a fatal exception occurs.
See Also:
getCancelDocument(javax.servlet.http.HttpServletRequest)

handleNoRowsAffected

protected void handleNoRowsAffected(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    Entity entity)
                             throws java.io.IOException,
                                    javax.servlet.ServletException
Handles the situation where no rows are affected when it is attempted to save the Entity to the database.

The default implementation returns the document from getNoRowsAffectedDocument(javax.servlet.http.HttpServletRequest) to the browser.

Parameters:
request - the request object.
response - the response object.
entity - Description of Parameter
Throws:
java.io.IOException - if an IO error occurs.
javax.servlet.ServletException - if a fatal exception occurs.
See Also:
getNoRowsAffectedDocument(javax.servlet.http.HttpServletRequest)

handleException

protected void handleException(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response,
                               java.lang.Exception exception,
                               Entity entity)
                        throws java.io.IOException,
                               javax.servlet.ServletException
Handles the situation where a Exception is caught when retrieving or saving an Entity.

The default implementation returns the document from getExceptionDocument(javax.servlet.http.HttpServletRequest, java.lang.Exception) to the browser.

Parameters:
request - the request object.
response - the response object.
exception - the Exception object.
entity - the current entity.
Throws:
java.io.IOException - if an IO error occurs.
javax.servlet.ServletException - if a fatal exception occurs.
See Also:
getSQLExceptionDocument(javax.servlet.http.HttpServletRequest, java.sql.SQLException)

handleSQLException

protected void handleSQLException(javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response,
                                  java.sql.SQLException exception,
                                  Entity entity)
                           throws java.io.IOException,
                                  javax.servlet.ServletException
Handles the situation where a SQLException is caught when retrieving or saving an Entity.

The default implementation returns the document from getSQLExceptionDocument(javax.servlet.http.HttpServletRequest, java.sql.SQLException) to the browser.

Parameters:
request - the request object.
response - the response object.
exception - the SQLException object.
entity - the current entity.
Throws:
java.io.IOException - if an IO error occurs.
javax.servlet.ServletException - if a fatal exception occurs.
See Also:
getSQLExceptionDocument(javax.servlet.http.HttpServletRequest, java.sql.SQLException)

handleSuccess

protected void handleSuccess(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             int rows,
                             Entity entity)
                      throws java.io.IOException,
                             javax.servlet.ServletException
Handles the situation where a delete, update or insert succeeded.

The default implementation checks to see if the entity was changed, and if the number of rows affectedis zero, passes control to handleNoRowsAffected(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.pajes.db.entity.Entity). Otherwise, it returns the document from getSuccessDocument(javax.servlet.http.HttpServletRequest) to the browser.

Parameters:
request - the request object.
response - the response object.
rows - the number of rows affected by the save.
entity - the entity being edited
Throws:
java.io.IOException - if an IO error occurs.
javax.servlet.ServletException - if a fatal exception occurs.

isCancelAction

protected boolean isCancelAction(java.lang.String action)
Determines if this is a request to cancel making changes to an entity.

Parameters:
action - the value of the ACTION_PARAMETERfor the current request.
Returns:
true if this is a request to cancel making changes to an entity and return to the list display.

isDeleteAction

protected boolean isDeleteAction(java.lang.String action)
Determines if this is a request to delete an entity. This method will only ever be called by the doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)method.

Parameters:
action - the value of the ACTION_PARAMETERfor the current request.
Returns:
true if this is a request to delete an entity.

isPermitted

protected boolean isPermitted(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws javax.servlet.ServletException,
                              java.io.IOException
Validates access to this servlet.

Parameters:
request - the request object.
response - the response object.
Returns:
true if this request may be processed, or false if access should be denied.
Throws:
javax.servlet.ServletException - if a fatal exception occurs.
java.io.IOException - if an IO error occurs.

isUpdateAction

protected boolean isUpdateAction(java.lang.String action)
Determines if this is a request to save a modified or new entity. This method will only ever be called by the doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)method.

Parameters:
action - the value of the ACTION_PARAMETERfor the current request.
Returns:
true if this is a request to save changes to an entity.

getErrorDocument

protected Paje getErrorDocument(javax.servlet.http.HttpServletRequest request,
                                java.lang.String message)
                         throws java.io.IOException
Creates a document that contains the user input and an error message.

Parameters:
request - the request object.
message - the error message.
Returns:
the HTML document.
Throws:
java.io.IOException - if an IO error occurs

onCreate

protected void onCreate(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response,
                        Paje doc)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Called by doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), when a CREATE_ACTION_VALUErequest is received, after creating the document to be returned to the browser. The default implementation does nothing.

Parameters:
request - the request object.
response - the response object.
doc - the document to be returned to the browser.
Throws:
javax.servlet.ServletException - if a fatal exception occurs.
java.io.IOException - if an IO error occurs.

onList

protected void onList(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      Paje lister)
               throws javax.servlet.ServletException,
                      java.io.IOException
Called by doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), when neither the CREATE_ACTION_VALUE, VIEW_ACTION_VALUEor MODIFY_ACTION_VALUEactions are specifed on the request, after creating the lister document to be returned to the browser. The default implementation does nothing.

Parameters:
request - the request object.
response - the response object.
lister - the lister document to be returned to the browser.
Throws:
javax.servlet.ServletException - if a fatal exception occurs.
java.io.IOException - if an IO error occurs.

onModify

protected void onModify(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response,
                        Paje doc)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Called by doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), when a MODIFY_ACTION_VALUErequest is received, after creating the document to be returned to the browser. The default implementation does nothing.

Parameters:
request - the request object.
response - the response object.
doc - the document to be returned to the browser.
Throws:
javax.servlet.ServletException - if a fatal exception occurs.
java.io.IOException - if an IO error occurs.

onView

protected void onView(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      Paje doc)
               throws javax.servlet.ServletException,
                      java.io.IOException
Called by doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), when a VIEW_ACTION_VALUErequest is received, after creating the document to be returned to the browser. The default implementation does nothing.

Parameters:
request - the request object.
response - the response object.
doc - the document to be returned to the browser.
Throws:
javax.servlet.ServletException - if a fatal exception occurs.
java.io.IOException - if an IO error occurs.

removeEntityFromSession

protected void removeEntityFromSession(javax.servlet.http.HttpServletRequest request,
                                       Entity entity)
Removes the specified Entity from the HttpSession.

Parameters:
request - the servlet request.
entity - the entity to be removed.

retrieveEntityBeforeUpdate

protected Entity retrieveEntityBeforeUpdate(Entity entity,
                                            Scope scope,
                                            boolean create)
                                     throws java.sql.SQLException
Retrieves the entity before applying the update.

Parameters:
entity - the entity from the session.
scope - the scope to retrieve the entity.
create - if true, the entity will be created if it does not exist. If false and the entity could not be retrieved,the passed-in entity will be returned.
Returns:
the entity to which the updated values will be applied. May be null if the create parameter was false and no entity was passed in.
Throws:
java.sql.SQLException - if a database access error occurs.

PAJES 3.0.21

Copyright 1998-2007 Viridian Pty Limited. All Rights Reserved.