ch7.accountRemove
Class ControllerHelper
java.lang.Object
shared.HelperBaseCh4
shared.HelperBaseCh5
shared.HelperBaseCh6
ch7.accountLogin.ControllerHelper
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.
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 objectresponse - Response information encapsulated in a Java object
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.
- Add the helper to the session but ignore the data from the old
helper in the session
- Always call the default method.
- 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.
- Add the helper to the session and copy the old helper data
into the current helper. This eliminates the need for hidden fields.
- 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.
- Forward the request and response to the next address.
- Overrides:
doPost in class ControllerHelper
- Throws:
javax.servlet.ServletException
java.io.IOException