com.acsinet_solutions.cetia4.controller.map
Class BeanRequestMapper

java.lang.Object
  extended by com.acsinet_solutions.cetia4.controller.map.AbstractBeanRequestMapper
      extended by com.acsinet_solutions.cetia4.controller.map.BeanRequestMapper
All Implemented Interfaces:
RequestMapper

public class BeanRequestMapper
extends AbstractBeanRequestMapper

This class helps to perform mapping between form information and a DTO. This class is used internally to perform mappings in various parts of the framework as it is very simple to use and highly configurable. It can also be used independently from any framework by instanciating it directly using a bean class as target ( also optional ) and calling any of the performMapping() methods if necessary. Portlet support for this class may also be added if necessary in future versions.

Author:
Santiago Arriaga

Constructor Summary
BeanRequestMapper()
          Create a request mapper with no default mappings.
BeanRequestMapper(java.lang.Class targetClass)
          Create a request mapper for the given targetClass using reflection mappings over its simple properties using a nesting level of 3.
BeanRequestMapper(java.lang.Class targetClass, int nestingLevel)
          Create a request mapper for the given targetClass using reflection mappings over its simple properties at an arbitrary nesting level for nesting properties.
 
Method Summary
 void performMapping(ParameterAccessor request, java.lang.Object bean)
          Perform the mapping from the HTTP request values to the provided bean using a generic parameter accesor API.
 void performMapping(javax.servlet.ServletRequest request, java.lang.Object bean)
          Perform the mapping from the HTTP request values to the provided bean in the case of the servlet API.
 
Methods inherited from class com.acsinet_solutions.cetia4.controller.map.AbstractBeanRequestMapper
addMapping, getLogger, getMapping, getMappings, getSimpleMapping, getTargetClass, performMapping, removeMapping, setMapping, setValidator, tryCreateMapping, validateAndCheck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanRequestMapper

public BeanRequestMapper()
Create a request mapper with no default mappings. mappings should be added to this class for it to be really useful ( unless a NOOP implementation is desired ).


BeanRequestMapper

public BeanRequestMapper(java.lang.Class targetClass)
Create a request mapper for the given targetClass using reflection mappings over its simple properties using a nesting level of 3. For arbitrary nesting level or no nesting use the more complete constructor.

See Also:
BeanRequestMapper(Class,int)

BeanRequestMapper

public BeanRequestMapper(java.lang.Class targetClass,
                         int nestingLevel)
Create a request mapper for the given targetClass using reflection mappings over its simple properties at an arbitrary nesting level for nesting properties. For no nesting properties, use 1 as value of nesting level ( 0 will result in an empty RequestMapper ).

Additional mappings may be added later, or undesired mappings may be removed if desired.

Default mappings are created using SimpleMapping.getDefaultMapping() method. All these are instances of SimpleMapping.

The name of the mapping will always correspond to the name of the mapped field. For example "text" property will correspond to "text" HTTP field. "note.id" nested property will correspond to "note.id" HTTP field.

Parameters:
targetClass - A not-null Class instance of the JavaBean type that will be mapped
See Also:
SimpleMapping.getDefaultMapping(String,Class)
Method Detail

performMapping

public final void performMapping(javax.servlet.ServletRequest request,
                                 java.lang.Object bean)
                          throws ValidationException
Description copied from interface: RequestMapper
Perform the mapping from the HTTP request values to the provided bean in the case of the servlet API.

Validation is performed in addition to the mapping, if a validator was set for the current request mapper.

Throws:
ValidationException
See Also:
RequestMapper.setValidator(Validator)

performMapping

public final void performMapping(ParameterAccessor request,
                                 java.lang.Object bean)
                          throws ValidationException
Description copied from interface: RequestMapper
Perform the mapping from the HTTP request values to the provided bean using a generic parameter accesor API. This allows to use the request mapping classes in a more wide variety of environments, not only web based.

Validation is performed in addition to the mapping, if a validator was set for the current request mapper.

Throws:
ValidationException
See Also:
RequestMapper.setValidator(Validator)