ch7.catalogAddress
Class ControllerHelper

java.lang.Object
  extended by shared.HelperBaseCh4
      extended by shared.HelperBaseCh5
          extended by shared.HelperBaseCh6
              extended by ch7.catalog.ControllerHelper
                  extended by ch7.catalogAddress.ControllerHelper

public class ControllerHelper
extends ControllerHelper

Does all the same actions as the catalog application and then obtains user information and saves it, like the ch5 Persistent Data application.


Nested Class Summary
 
Nested classes/interfaces inherited from class shared.HelperBaseCh4
HelperBaseCh4.SessionData
 
Field Summary
protected  RequestDataPersistent data
          The member variable that will store the bean, which encapsulates the data for the application.
 
Fields inherited from class ch7.catalog.ControllerHelper
cart, item
 
Fields inherited from class shared.HelperBaseCh6
checked, selected
 
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
 java.lang.String confirmMethod()
          The method that preforms the actions associated with the confirm button.
 void copyFromSession(java.lang.Object sessionHelper)
          Most of the details for retrieving data from the session are implemented in the helper base class.
 java.lang.String editMethod()
          The method that preforms the actions associated with the edit button.
 java.lang.Object getData()
          Accessor that returns the bean.
static void initHibernate(boolean create)
          Uses properties to set the configuration parameters for Hibernate.
 java.lang.String jspLocation(java.lang.String page)
          Generates the full path to a JSP.
 java.lang.String processMethod()
          The method that preforms the actions associated with the process button.
 
Methods inherited from class ch7.catalog.ControllerHelper
doGet, doPost, getCart, getItem, methodAddCart, methodDefault, methodEmptyCart, methodProcessCart, methodViewCart, methodViewItem
 
Methods inherited from class shared.HelperBaseCh6
addChecked, addChoice, addSelected, clearMaps, clearProperty, getChecked, getSelected, invokeGetter, setCheckedAndSelected, setCheckedAndSelected
 
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
 

Field Detail

data

protected RequestDataPersistent data
The member variable that will store the bean, which encapsulates the data for the application. This bean will have Hibernate annotations to implement validation.

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.

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.

getData

public java.lang.Object getData()
Accessor that returns the bean. This accessor is required so that the bean can be retrieved from a JSP, using the expression language. Only public accessors and mutators can be accessed using the expression language.

Returns:
The bean for this application.

copyFromSession

public void copyFromSession(java.lang.Object sessionHelper)
Most of the details for retrieving data from the session are implemented in the helper base class. The specific details concerning the actual data must be implemented in the controller helper, since each application can have different data. The specific details are implemented in this method; it is the implementation of an abstract method in the helper base class.

Overrides:
copyFromSession in class ControllerHelper
Parameters:
sessionHelper - The object that represents the controller helper that was added to the session in the previous request.

During each request, the controller helper is placed in the session. Before that happens, the controller helper from the previous request can be retrieved from the session. This object is retrieved in the helper base class and sent to the implementation of this abstract method.

This application has three beans, so all three must be copied from the session.


jspLocation

public java.lang.String jspLocation(java.lang.String page)
Generates the full path to a JSP.

Overrides:
jspLocation in class ControllerHelper
Parameters:
page - The name of the JSP. This will be appended to the path of the directory that contains the JSPs. Using this method forces all the JSPs to be in the same directory.
Returns:
The string that represents the complete path to the JSP. This path must be relative to the directory where the servlet is mapped or must begin with a /, which represents the root of the web application.

editMethod

public java.lang.String editMethod()
The method that preforms the actions associated with the edit button.

Returns:
The address of the JSP that will complete the request.

confirmMethod

public java.lang.String confirmMethod()
The method that preforms the actions associated with the confirm button. Implements required validation.

Returns:
The address of the JSP that will complete the request.

processMethod

public java.lang.String processMethod()
The method that preforms the actions associated with the process button. Saves the bean to the database. Additionaly, it retrieves all the data from the database and places it in the request, so that the results can be retrived in a JSP.

Returns:
The address of the JSP that will complete the request.