org.kuali.rice.kns.web.struts.pojo
Class PojoFormBase

java.lang.Object
  extended by org.apache.struts.action.ActionForm
      extended by org.kuali.rice.kns.web.struts.pojo.PojoFormBase
All Implemented Interfaces:
Serializable, PojoForm
Direct Known Subclasses:
KualiForm

public class PojoFormBase
extends org.apache.struts.action.ActionForm
implements PojoForm

This class is the base form which implements the PojoForm interface. Kuali Foundation modification: javadoc comments changed

See Also:
Serialized Form

Field Summary
protected  Set<String> requiredNonEditableProperties
           
 
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
 
Constructor Summary
PojoFormBase()
           
 
Method Summary
protected  void addMaxUploadSize(String sizeString)
          Adds the given string as a maximum size to the form.
 void addRequiredNonEditableProperties()
          This method adds the required property names, that are not directly editable by user on the html page, to a list, regardless of the context in which they appear.
protected  void cacheUnconvertedValue(String key, Object value)
           
 void clearEditablePropertyInformation()
          Reinitializes the form to allow it to register the editable properties of the currently processing request.
 void copyPopulateEditablePropertiesToActionEditableProperties()
          Copies all editable properties in the populate editable properties to the action editable properties
protected  void customInitMaxUploadSizes()
          Subclasses can override this to add their own max upload size to the list.
protected  Class formatterClassForKeypath(String keypath)
          Retrieves any formatters associated specially with the keypath.
 Object formatValue(Object value, String keypath, Class type)
          Tries to format the provided value by passing it to a suitable Formatter.
 String getActionEditablePropertiesGuid()
           
 Set<String> getEditableProperties()
           
protected  Formatter getFormatter(String keypath, Class propertyType)
          Retrieves a formatter for the keypath and property type.
 Map getFormatterTypes()
          Gets the formatterTypes attribute.
 boolean getIsNewForm()
           
 List<String> getMaxUploadSizes()
           
 Set<String> getMethodToCallsToBypassSessionRetrievalForGETRequests()
          Base implementation that returns just "start".
protected  String getParameter(javax.servlet.http.HttpServletRequest request, String parameterName)
           
protected  String[] getParameterValues(javax.servlet.http.HttpServletRequest request, String parameterName)
           
 Set<String> getPopulateEditableProperties()
           
 String getPopulateEditablePropertiesGuid()
           
protected  Class getPropertyType(String keypath)
          Delegates to PropertyUtils.getPropertyType(Object, String)to look up the property type for the provided keypath.
 Set<String> getRequiredNonEditableProperties()
           
 String getStrutsActionMappingScope()
           
 Map getUnconvertedValues()
           
protected  List getUnknownKeys()
           
protected  void initMaxUploadSizes()
          Initializes the list of max upload sizes if necessary.
 boolean isPropertyEditable(String propertyName)
           
 boolean isPropertyNonEditableButRequired(String propertyName)
           
 void populate(javax.servlet.http.HttpServletRequest request)
          Populates the form with values from the current request.
protected  void populateForProperty(String paramPath, Object paramValue, Map params)
          Populates a given parameter value into the given property path
 void postprocessRequestParameters(Map requestParameters)
          Method is called after parameters from a multipart request have been made accessible to request.getParameter calls, but before request parameter values are used to instantiate and populate business objects.
 void processValidationFail()
           
 void registerEditableProperty(String editablePropertyName)
           
 void registerIsNewForm(boolean isNewForm)
           
 void registerRequiredNonEditableProperty(String requiredNonEditableProperty)
           
 void registerStrutsActionMappingScope(String strutsActionMappingScope)
          Sets the value of the "scope" attribute for the Struts action mapping corresponding to this form instance.
 void setActionEditablePropertiesGuid(String guid)
          Sets the guid of the editable properties which were registered by the action
 void setFormatterType(String keypath, Class type)
          Sets the Formatter class to use for a given keypath.
 void setFormatterTypes(Map formatterTypes)
          Sets the formatterTypes attribute value.
 void setPopulateEditablePropertiesGuid(String guid)
          Sets the guid to editable properties consulted during population
 void setUnconvertedValues(Map unconvertedValues)
           
 boolean shouldPropertyBePopulatedInForm(String requestParameterName, javax.servlet.http.HttpServletRequest request)
          Returns whether a request parameter should be populated as a property of the form, assuming that the request parameter name corresponds to a property on the form.
 
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, reset, reset, setMultipartRequestHandler, setServlet, validate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requiredNonEditableProperties

protected Set<String> requiredNonEditableProperties
Constructor Detail

PojoFormBase

public PojoFormBase()
Method Detail

postprocessRequestParameters

public void postprocessRequestParameters(Map requestParameters)
Method is called after parameters from a multipart request have been made accessible to request.getParameter calls, but before request parameter values are used to instantiate and populate business objects. Important note: parameters in the given Map which were created from a multipart-encoded parameter will, apparently, be stored in the given Map as String[] instead of as String.

Specified by:
postprocessRequestParameters in interface PojoForm
Parameters:
requestParameters -

populate

public void populate(javax.servlet.http.HttpServletRequest request)
Populates the form with values from the current request. Uses instances of Formatter to convert strings to the Java types of the properties to which they are bound. Values that can't be converted are cached in a map of unconverted values. Returns an ActionErrors containing ActionMessage instances for each conversion error that occured, if any.

Specified by:
populate in interface PojoForm

populateForProperty

protected void populateForProperty(String paramPath,
                                   Object paramValue,
                                   Map params)
Populates a given parameter value into the given property path

Parameters:
paramPath - the path to a property within the form
paramValue - the value of that property
params - the Map of parameters from the request

getPropertyType

protected Class getPropertyType(String keypath)
                         throws IllegalAccessException,
                                InvocationTargetException,
                                NoSuchMethodException
Delegates to PropertyUtils.getPropertyType(Object, String)to look up the property type for the provided keypath. Caches the resulting class so that subsequent lookups for the same keypath can be satisfied by looking in the cache.

Throws:
NoSuchMethodException
InvocationTargetException
IllegalAccessException

getFormatter

protected Formatter getFormatter(String keypath,
                                 Class propertyType)
Retrieves a formatter for the keypath and property type.

Parameters:
keypath -
propertyType -
Returns:

formatterClassForKeypath

protected Class formatterClassForKeypath(String keypath)
Retrieves any formatters associated specially with the keypath.

Parameters:
keypath -
Returns:

formatValue

public Object formatValue(Object value,
                          String keypath,
                          Class type)
Tries to format the provided value by passing it to a suitable Formatter. Adds an ActionMessage to the ActionErrors in the request if a FormatException is thrown.

Caution should be used when invoking this method. It should never be called prior to populate(HttpServletRequest) because the cached request reference could be stale.

Specified by:
formatValue in interface PojoForm

setFormatterType

public void setFormatterType(String keypath,
                             Class type)
Sets the Formatter class to use for a given keypath. This class will be used by the form instead of the one returned by calls to Formatter.getFormatter(Class), which is the default mechanism.


getUnconvertedValues

public Map getUnconvertedValues()
Specified by:
getUnconvertedValues in interface PojoForm

setUnconvertedValues

public void setUnconvertedValues(Map unconvertedValues)

getUnknownKeys

protected List getUnknownKeys()

cacheUnconvertedValue

protected void cacheUnconvertedValue(String key,
                                     Object value)

processValidationFail

public void processValidationFail()
Specified by:
processValidationFail in interface PojoForm

getFormatterTypes

public Map getFormatterTypes()
Gets the formatterTypes attribute.

Returns:
Returns the formatterTypes.

setFormatterTypes

public void setFormatterTypes(Map formatterTypes)
Sets the formatterTypes attribute value.

Parameters:
formatterTypes - The formatterTypes to set.

addMaxUploadSize

protected final void addMaxUploadSize(String sizeString)
Adds the given string as a maximum size to the form. It will be used if a file upload is used.

Parameters:
sizeString -

initMaxUploadSizes

protected final void initMaxUploadSizes()
Initializes the list of max upload sizes if necessary.


customInitMaxUploadSizes

protected void customInitMaxUploadSizes()
Subclasses can override this to add their own max upload size to the list. Only the largest passed will be used.


getMaxUploadSizes

public final List<String> getMaxUploadSizes()

registerEditableProperty

public void registerEditableProperty(String editablePropertyName)
Specified by:
registerEditableProperty in interface PojoForm

registerRequiredNonEditableProperty

public void registerRequiredNonEditableProperty(String requiredNonEditableProperty)

clearEditablePropertyInformation

public void clearEditablePropertyInformation()
Description copied from interface: PojoForm
Reinitializes the form to allow it to register the editable properties of the currently processing request.

Specified by:
clearEditablePropertyInformation in interface PojoForm

getEditableProperties

public Set<String> getEditableProperties()
Specified by:
getEditableProperties in interface PojoForm

isPropertyEditable

public boolean isPropertyEditable(String propertyName)

addRequiredNonEditableProperties

public void addRequiredNonEditableProperties()
Description copied from interface: PojoForm
This method adds the required property names, that are not directly editable by user on the html page, to a list, regardless of the context in which they appear. Request parameter names corresponding to these properties will be populated into the form.

Specified by:
addRequiredNonEditableProperties in interface PojoForm
See Also:
PojoForm.addRequiredNonEditableProperties()

isPropertyNonEditableButRequired

public boolean isPropertyNonEditableButRequired(String propertyName)

getParameter

protected String getParameter(javax.servlet.http.HttpServletRequest request,
                              String parameterName)

getParameterValues

protected String[] getParameterValues(javax.servlet.http.HttpServletRequest request,
                                      String parameterName)

getRequiredNonEditableProperties

public Set<String> getRequiredNonEditableProperties()
Specified by:
getRequiredNonEditableProperties in interface PojoForm

registerStrutsActionMappingScope

public void registerStrutsActionMappingScope(String strutsActionMappingScope)
Description copied from interface: PojoForm
Sets the value of the "scope" attribute for the Struts action mapping corresponding to this form instance. Note that this method name is NOT in the syntax of the conventional POJO setter; this is to prevent clients from maliciously altering the value of this parameter

Specified by:
registerStrutsActionMappingScope in interface PojoForm
See Also:
PojoForm.registerStrutsActionMappingScope(String)

getStrutsActionMappingScope

public String getStrutsActionMappingScope()

registerIsNewForm

public void registerIsNewForm(boolean isNewForm)
Specified by:
registerIsNewForm in interface PojoForm
See Also:
PojoForm.registerStrutsActionMappingScope(String)

getIsNewForm

public boolean getIsNewForm()
Specified by:
getIsNewForm in interface PojoForm

shouldPropertyBePopulatedInForm

public boolean shouldPropertyBePopulatedInForm(String requestParameterName,
                                               javax.servlet.http.HttpServletRequest request)
Description copied from interface: PojoForm
Returns whether a request parameter should be populated as a property of the form, assuming that the request parameter name corresponds to a property on the form. This method makes no determination whether the request parameter is a property of the form, but rather from a security perspective, whether the framework should attempt to set the form property with the same name as the request parameter.

Specified by:
shouldPropertyBePopulatedInForm in interface PojoForm
Parameters:
requestParameterName - the name of the request parameter
request - the HTTP request
Returns:
whether the parameter should be
See Also:
PojoForm.shouldPropertyBePopulatedInForm(java.lang.String, javax.servlet.http.HttpServletRequest)

getMethodToCallsToBypassSessionRetrievalForGETRequests

public Set<String> getMethodToCallsToBypassSessionRetrievalForGETRequests()
Base implementation that returns just "start". sub-implementations should not add values to Set instance returned by this method, and should create its own instance.

Specified by:
getMethodToCallsToBypassSessionRetrievalForGETRequests in interface PojoForm
Returns:
See Also:
PojoForm.getMethodToCallsToBypassSessionRetrievalForGETRequests()

setPopulateEditablePropertiesGuid

public void setPopulateEditablePropertiesGuid(String guid)
Sets the guid to editable properties consulted during population

Specified by:
setPopulateEditablePropertiesGuid in interface PojoForm
Parameters:
guid - the key to the editable properties for this form
See Also:
org.kuali.rice.kns.web.struts.pojo.PojoForm#setEditablePropertiesGuid(java.lang.String)

getPopulateEditablePropertiesGuid

public String getPopulateEditablePropertiesGuid()
Returns:
the guid for the populate editable properties

setActionEditablePropertiesGuid

public void setActionEditablePropertiesGuid(String guid)
Sets the guid of the editable properties which were registered by the action

Specified by:
setActionEditablePropertiesGuid in interface PojoForm
Parameters:
guid - the guid of the action editable properties
See Also:
PojoForm.setActionEditablePropertiesGuid(java.lang.String)

getActionEditablePropertiesGuid

public String getActionEditablePropertiesGuid()
Returns:
the guid of the editable properties which had been registered by the action processing

getPopulateEditableProperties

public Set<String> getPopulateEditableProperties()
Returns:
the editable properties to be consulted during population

copyPopulateEditablePropertiesToActionEditableProperties

public void copyPopulateEditablePropertiesToActionEditableProperties()
Copies all editable properties in the populate editable properties to the action editable properties



Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.