ch7.accountRemove
Class ControllerHelper

java.lang.Object
  extended by shared.HelperBaseCh4
      extended by shared.HelperBaseCh5
          extended by shared.HelperBaseCh6
              extended by ch7.accountLogin.ControllerHelper
                  extended by ch7.accountRemove.ControllerHelper

public class ControllerHelper
extends ControllerHelper

After data has been saved to the database, the user is given the option to remove the data.


Nested Class Summary
 
Nested classes/interfaces inherited from class shared.HelperBaseCh4
HelperBaseCh4.SessionData
 
Field Summary
 
Fields inherited from class ch7.accountLogin.ControllerHelper
data
 
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)
          Call the base class constructor to store the request and response.
 
Method Summary
protected  void doGet()
          Call the method in the super class.
protected  void doPost()
          Call the method in the super class.
 java.lang.String jspLocation(java.lang.String page)
          Encapsulates the location of the JSPs.
 java.lang.String removeMethod()
          The method to call when the removeButton button is clicked.
 
Methods inherited from class ch7.accountLogin.ControllerHelper
confirmMethod, copyFromSession, editMethod, getData, getMethod, initHibernate, loginMethod, newUserMethod, processMethod
 
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, 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)
Call the base class constructor to store the request and response.

Parameters:
request - Request information encapsulated in a Java object
response - Response information encapsulated in a Java object
Method Detail

jspLocation

public java.lang.String jspLocation(java.lang.String page)
Encapsulates the location of the JSPs.

Overrides:
jspLocation in class ControllerHelper
Parameters:
page - The file name of the JSP.
Returns:
The full path to the JSP.

removeMethod

public java.lang.String removeMethod()
The method to call when the removeButton button is clicked.

Remove the current bean from the database. If the bean is not in the database, then the remove command is ignored.

Delete the current bean so that there is not a stale bean that refers to the database.

The method is adorned with a ButtonMethod annotation that associates the name of a button with the method.

Returns:
The address for the JSP.

doGet

protected void doGet()
              throws javax.servlet.ServletException,
                     java.io.IOException
Call the method in the super class.

GET is considered a new request, so the old data is not read and the JSP is always for the edit page.

  1. Add the helper to the session but ignore the data from the old helper in the session
  2. Always call the default method.
  3. Forward the request and response to the next address.

Overrides:
doGet in class ControllerHelper
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

protected void doPost()
               throws javax.servlet.ServletException,
                      java.io.IOException
Call the method in the super class.

POST is considered a continuation of a previous request, so read the old data from the session and calculate the next page based on the button.

  1. Add the helper to the session and copy the old helper data into the current helper. This eliminates the need for hidden fields.
  2. Call the appropriate method for the clicked button. This is done from a method in the helper base that loops throuh all the button methods, looking for the one for the clicked button. This eliminates the need for the nested if-else block.
  3. Forward the request and response to the next address.

Overrides:
doPost in class ControllerHelper
Throws:
javax.servlet.ServletException
java.io.IOException