ch6.complexForm
Class ControllerHelper

java.lang.Object
  extended by shared.HelperBaseCh4
      extended by shared.HelperBaseCh5
          extended by shared.HelperBaseCh6
              extended by ch6.complexForm.ControllerHelper

public class ControllerHelper
extends HelperBaseCh6

Calls resetNullable to clear advanced HTML form elements.

Some advanced form elements do not place anything in the query string if nothing is selected. These elements must be cleared before new data is copied to the bean.


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
 java.lang.String confirmMethod()
          The method to call when the confirm button is clicked.
 void copyFromSession(java.lang.Object sessionHelper)
          The implementation of the abstract method from the helper base.
protected  void doGet()
          Handles Get requests.
 java.lang.String editMethod()
          The method to call when the edit button is clicked.
 java.lang.Object getData()
          An accessor that allows the JSPs to retrieve the bean from the helper.
protected  java.lang.String jspLocation(java.lang.String page)
          Encapsulates the location of the JSPs.
 java.lang.String processMethod()
          The method to call when the process button is clicked.
 void resetNullable()
          Certain advanced form elements must be manually cleared, since there will be no data in the query string if nothing is selected.
 
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, doPost, 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

getData

public java.lang.Object getData()
An accessor that allows the JSPs to retrieve the bean from the helper.

Returns:
The bean that contains the data from the request.

copyFromSession

public void copyFromSession(java.lang.Object sessionHelper)
The implementation of the abstract method from the helper base.

The method copies data from the old helper that is still in the session to the current helper.

Specified by:
copyFromSession in class HelperBaseCh4
Parameters:
sessionHelper - The old helper that is still in the session.

resetNullable

public void resetNullable()
Certain advanced form elements must be manually cleared, since there will be no data in the query string if nothing is selected.


jspLocation

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

Parameters:
page - The file name of the JSP.
Returns:
The full path to the JSP.

editMethod

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

The method does nothing else at this time than indicate the address of the page.

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

Returns:
The address for the JSP.

confirmMethod

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

Reset all elements that are nullable.

Use the fillBeanFromRequest method to automatically copy the request data into the bean.

Implement required validation by calling isValid. If the data is valid, then proceed to the confirm page; otherwise, return to the edit page.

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

Returns:
The address for the JSP.

processMethod

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

The method does nothing else at this time than indicate the address of the page.

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
Handles Get requests.
  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:
doGet in class HelperBaseCh4
Throws:
javax.servlet.ServletException
java.io.IOException