ch5.persistentData.configure
Class ControllerHelper

java.lang.Object
  extended by shared.HelperBaseCh4
      extended by shared.HelperBaseCh5
          extended by ch5.persistentData.ControllerHelper
              extended by ch5.persistentData.configure.ControllerHelper

public class ControllerHelper
extends ControllerHelper

Saves the bean to a database. Hibernate will be initialised in the initHibernate method. The process method will save the data to the database and set the results of a query in the request, which can be retrieved in a bean.


Nested Class Summary
 
Nested classes/interfaces inherited from class shared.HelperBaseCh4
HelperBaseCh4.SessionData
 
Field Summary
 
Fields inherited from class ch5.persistentData.ControllerHelper
data
 
Fields inherited from class shared.HelperBaseCh4
logger, request, response
 
Constructor Summary
ControllerHelper(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          The only constructor for this class has parameters for the request and response objects.
 
Method Summary
protected  void doGet()
          This method will be called by the controller to finish processing the request.
protected  void doPost()
          This method will be called by the controller to finish processing the request.
static void initHibernate(boolean create)
          Uses properties to set the configuration parameters for Hibernate.
 
Methods inherited from class ch5.persistentData.ControllerHelper
confirmMethod, copyFromSession, editMethod, getData, jspLocation, processMethod
 
Methods inherited from class shared.HelperBaseCh5
getErrors, isValid, isValidProperty, setErrors
 
Methods inherited from class shared.HelperBaseCh4
addHelperToSession, addHelperToSession, executeButtonMethod, executeButtonMethod, fillBeanFromRequest, invokeButtonMethod, populateThrow, writeError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControllerHelper

public ControllerHelper(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response)
The only constructor for this class has parameters for the request and response objects. These objects will be stored in member variables.

Parameters:
request - The object that encapsulates the request information that is needed to communicate with the browser.
response - The object that encapsulates the response information that is needed to communicate with the browser.
Method Detail

initHibernate

public static void initHibernate(boolean create)
Uses properties to set the configuration parameters for Hibernate. Three properties must be changed: connection string, username and password.

Parameters:
create - If there is an initilization parameter named 'create' in the web.xml file, then its value will be sent to this method. If it is true, then it means that the table for the bean should be created in the database.

doGet

protected void doGet()
              throws javax.servlet.ServletException,
                     java.io.IOException
This method will be called by the controller to finish processing the request. The controller is the servlet, so its doGet method will be called by the servlet engine. The controller will then call this doGet method.

GET requests will be treated as first requests to the application. Previous data will not be retrieved from the session and the edit page will always be displayed.

Overrides:
doGet in class ControllerHelper
Throws:
javax.servlet.ServletException - A servlet exception is a severe error and means that processing cannot continue.
java.io.IOException - An IO exception is a severe error and means that processing cannot continue.

doPost

protected void doPost()
               throws javax.servlet.ServletException,
                      java.io.IOException
This method will be called by the controller to finish processing the request. The controller is the servlet, so its doPost method will be called by the servlet engine. The controller will then call this doPost method.

POST requests will implement the controller logic that has been in all previous controllers.

Overrides:
doPost in class ControllerHelper
Throws:
javax.servlet.ServletException - A servlet exception is a severe error and means that processing cannot continue.
java.io.IOException - An IO exception is a severe error and means that processing cannot continue.