shared
Class HelperBaseCh6

java.lang.Object
  extended by shared.HelperBaseCh4
      extended by shared.HelperBaseCh5
          extended by shared.HelperBaseCh6
Direct Known Subclasses:
ControllerHelper, ControllerHelper, ControllerHelper, ControllerHelper, ControllerHelper, ControllerHelper, ControllerHelper

public abstract class HelperBaseCh6
extends HelperBaseCh5

Helper base for Chapters 6 and 7.


Nested Class Summary
 
Nested classes/interfaces inherited from class shared.HelperBaseCh4
HelperBaseCh4.SessionData
 
Field Summary
protected  java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> checked
          Map of checked form elements.
protected  java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> selected
          Map of selected form elements.
 
Fields inherited from class shared.HelperBaseCh4
logger, request, response
 
Constructor Summary
HelperBaseCh6(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Call the super class to initialise the request and response.
 
Method Summary
 void addChecked(java.lang.String group, java.lang.String item)
          Add an entry in the checked map for the group and item.
 void addChoice(java.lang.String list, java.lang.String item, AttributeType type)
          Add an entry in the selected or checked map for the list and item.
 void addSelected(java.lang.String list, java.lang.String item)
          Add an entry in the selected map for the group and item.
 void clearMaps()
          Clear all the sub-maps from the checked and selected maps.
 void clearProperty(java.lang.String property, AttributeType type)
          Delete the sub-map for a property.
 java.util.Map getChecked()
          Accessor for the checked map, to allow JSPs to access it.
 java.util.Map getSelected()
          Accessor for the selected map, to allow JSPs to access it.
protected  java.lang.Object invokeGetter(java.lang.Object obj, java.lang.reflect.Method method)
          Call the getter.
protected  void setCheckedAndSelected(java.lang.Object data)
          Fill the checked map and selected map with values from the query string for bean properties that have been marked with the SetByAttribute annotation.
protected  void setCheckedAndSelected(java.lang.Object data, java.lang.Class clazz)
          Fill the checked map and selected map with values from the query string for bean properties that have been marked with the SetByAttribute annotation.
 
Methods inherited from class shared.HelperBaseCh5
getErrors, isValid, isValidProperty, setErrors
 
Methods inherited from class shared.HelperBaseCh4
addHelperToSession, addHelperToSession, copyFromSession, doGet, doPost, executeButtonMethod, executeButtonMethod, fillBeanFromRequest, invokeButtonMethod, writeError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

checked

protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> checked
Map of checked form elements. The map is indexed by the name of the radio or checkbox group and contains a map of values that are checked.


selected

protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> selected
Map of selected form elements. The map is indexed by the name of the select list and contains a map of values that are checked.

Constructor Detail

HelperBaseCh6

public HelperBaseCh6(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
Call the super class to initialise the request and response.

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

setCheckedAndSelected

protected void setCheckedAndSelected(java.lang.Object data)
Fill the checked map and selected map with values from the query string for bean properties that have been marked with the SetByAttribute annotation.

Parameters:
data - The bean that contains the data

setCheckedAndSelected

protected void setCheckedAndSelected(java.lang.Object data,
                                     java.lang.Class clazz)
Fill the checked map and selected map with values from the query string for bean properties that have been marked with the SetByAttribute annotation.

Parameters:
data - The bean that contains the data
clazz - The class of the bean that contains the data

invokeGetter

protected java.lang.Object invokeGetter(java.lang.Object obj,
                                        java.lang.reflect.Method method)
Call the getter. Log errors.

Parameters:
obj - The object that contains the method to invoke
method - The method to invoke
Returns:

getChecked

public java.util.Map getChecked()
Accessor for the checked map, to allow JSPs to access it.

Returns:
checked map

getSelected

public java.util.Map getSelected()
Accessor for the selected map, to allow JSPs to access it.

Returns:
selected map

addChecked

public void addChecked(java.lang.String group,
                       java.lang.String item)
Add an entry in the checked map for the group and item.

Parameters:
group - The name of the HTML element
item - The value of the HTML element

addSelected

public void addSelected(java.lang.String list,
                        java.lang.String item)
Add an entry in the selected map for the group and item.

Parameters:
list - The name of the HTML element
item - The value of the HTML element

addChoice

public void addChoice(java.lang.String list,
                      java.lang.String item,
                      AttributeType type)
Add an entry in the selected or checked map for the list and item.

Parameters:
list - The name of the HTML element
item - The value of the HTML element
type - The type of element: checked or selected

clearProperty

public void clearProperty(java.lang.String property,
                          AttributeType type)
Delete the sub-map for a property.

Parameters:
property - The name of the HTML element
type - The type of the HTML element: checked or selected

clearMaps

public void clearMaps()
Clear all the sub-maps from the checked and selected maps.