|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectshared.HelperBaseCh4
shared.HelperBaseCh5
shared.HelperBaseCh6
ch7.catalog.ControllerHelper
public class ControllerHelper
Uses two beans: one for the shopping cart and one for the current item
The cart will be placed in the session. The current item displayed on the page will be stored in a bean in the session, too.
This is the first application that has two beans. It will be necessary to add accessors for each of them, so the JSPs can retrieve them. It will also be necessary to copy them from the old session data.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class shared.HelperBaseCh4 |
|---|
HelperBaseCh4.SessionData |
| Field Summary |
|---|
| 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 | |
|---|---|
void |
copyFromSession(java.lang.Object sessionHelper)
The implementation of the abstract method from the helper base. |
protected void |
doGet()
GET is considered a new request, so the old data is not read and the JSP is always for the edit page. |
protected void |
doPost()
Handles the HTTP POST method. |
java.lang.Object |
getCart()
Accessor for the shopping cart. |
java.lang.Object |
getItem()
Accessor for the current item in the page. |
static void |
initHibernate(boolean create)
The properties are in the hibernate.cfg.xml file. |
java.lang.String |
jspLocation(java.lang.String page)
Encapsulates the location of the JSPs. |
java.lang.String |
methodAddCart()
The method to call when the addCart button is clicked. |
java.lang.String |
methodDefault()
The default method, it is not associated with any button. |
java.lang.String |
methodEmptyCart()
The method to call when the emptyCart button is clicked. |
java.lang.String |
methodProcessCart()
The method to call when the processCart button is clicked. |
java.lang.String |
methodViewCart()
The method to call when the viewCart button is clicked. |
java.lang.String |
methodViewItem()
The method to call when the viewItem button is clicked. |
| 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 |
|---|
public ControllerHelper(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - Request information encapsulated in a Java objectresponse - Response information encapsulated in a Java object| Method Detail |
|---|
public static void initHibernate(boolean create)
The data has already been created, so there is not need to call createTable.
create - true means create the table, false means do not createpublic java.lang.Object getItem()
The accessor is necessary so that the JSPs can access the item.
public java.lang.Object getCart()
The accessor is necessary so that the JSPs can access the cart.
public void copyFromSession(java.lang.Object sessionHelper)
The method copies item and the cart from the old helper that is still in the session to the current helper.
copyFromSession in class HelperBaseCh4sessionHelper - The old helper that is still in the session.public java.lang.String jspLocation(java.lang.String page)
page - The file name of the JSP.
public java.lang.String methodDefault()
Place all of the items from the catalog database in a list and place it in the request, so that the JSP can access it.
The method is adorned with a ButtonMethod annotation that associates the name of a button with the method.
public java.lang.String methodAddCart()
Use the cart bean to add the current item to the shopping cart. It is critical to reset the current item to a new item; otherwise, the current item will point into the shopping cart.
The method is adorned with a ButtonMethod annotation that associates the name of a button with the method.
public java.lang.String methodEmptyCart()
Use the cart bean to remove all the items from the shopping cart.
The method is adorned with a ButtonMethod annotation that associates the name of a button with the method.
public java.lang.String methodViewItem()
Fill the item bean with the item from the request. If there is an associated item in the catalog database, set it as the current item.
The method is adorned with a ButtonMethod annotation that associates the name of a button with the method.
public java.lang.String methodViewCart()
The method only directs the request to the cart page
The method is adorned with a ButtonMethod annotation that associates the name of a button with the method.
public java.lang.String methodProcessCart()
Loops through all the items in the cart and calculates the total number of items and the total price.
The method is adorned with a ButtonMethod annotation that associates the name of a button with the method.
protected void doGet()
throws java.io.IOException,
javax.servlet.ServletException
doGet in class HelperBaseCh4javax.servlet.ServletException
java.io.IOException
protected void doPost()
throws javax.servlet.ServletException,
java.io.IOException
POST method.
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.
doPost in class HelperBaseCh4javax.servlet.ServletException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||