org.codehaus.groovy.grails.web.binding
Class GrailsDataBinder

java.lang.Object
  extended by org.springframework.validation.DataBinder
      extended by org.springframework.web.bind.WebDataBinder
          extended by org.springframework.web.bind.ServletRequestDataBinder
              extended by org.codehaus.groovy.grails.web.binding.GrailsDataBinder
All Implemented Interfaces:
PropertyEditorRegistry, TypeConverter

public class GrailsDataBinder
extends ServletRequestDataBinder

A data binder that handles binding dates that are specified with a "struct"-like syntax in request parameters. For example for a set of fields defined as:

This would set the property "myDate" of type java.util.Date with the specified values.

Since:
05-Jan-2006
Author:
Graeme Rocher

Field Summary
protected  BeanWrapper bean
           
static String DEFAULT_DATE_FORMAT
           
static String[] DOMAINCLASS_DISALLOWED
           
static String[] GROOVY_DISALLOWED
           
static String[] GROOVY_DOMAINCLASS_DISALLOWED
           
static String NULL_ASSOCIATION
           
 
Fields inherited from class org.springframework.web.bind.WebDataBinder
DEFAULT_FIELD_DEFAULT_PREFIX, DEFAULT_FIELD_MARKER_PREFIX
 
Fields inherited from class org.springframework.validation.DataBinder
DEFAULT_OBJECT_NAME, logger
 
Constructor Summary
GrailsDataBinder(Object target, String objectName)
          Create a new GrailsDataBinder instance.
 
Method Summary
protected  void autoCreateIfPossible(MutablePropertyValues mpvs)
          Method that auto-creates the a type if it is null and is possible to auto-create
 void bind(org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap params)
          Binds from a GrailsParameterMap object
 void bind(org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap params, String prefix)
           
 void bind(PropertyValues propertyValues)
           
 void bind(PropertyValues propertyValues, String prefix)
           
 void bind(ServletRequest request)
           
 void bind(ServletRequest request, String prefix)
           
protected  void bindAssociations(MutablePropertyValues mpvs)
          Interrogates the specified properties looking for properites that represent associations to other classes (e.g., 'author.id').
static GrailsDataBinder createBinder(Object target, String objectName)
          Utility method for creating a GrailsDataBinder instance
static GrailsDataBinder createBinder(Object target, String objectName, HttpServletRequest request)
          Utility method for creating a GrailsDataBinder instance
protected  void doBind(MutablePropertyValues mpvs)
           
static void registerCustomEditors(PropertyEditorRegistry registry, Locale locale)
          Registers all known
 
Methods inherited from class org.springframework.web.bind.ServletRequestDataBinder
closeNoCatch
 
Methods inherited from class org.springframework.web.bind.WebDataBinder
bindMultipartFiles, checkFieldDefaults, checkFieldMarkers, getEmptyValue, getFieldDefaultPrefix, getFieldMarkerPrefix, isBindEmptyMultipartFiles, setBindEmptyMultipartFiles, setFieldDefaultPrefix, setFieldMarkerPrefix
 
Methods inherited from class org.springframework.validation.DataBinder
applyPropertyValues, checkAllowedFields, checkRequiredFields, close, convertIfNecessary, convertIfNecessary, findCustomEditor, getAllowedFields, getBindingErrorProcessor, getBindingResult, getConversionService, getDisallowedFields, getErrors, getInternalBindingResult, getObjectName, getPropertyAccessor, getPropertyEditorRegistry, getRequiredFields, getSimpleTypeConverter, getTarget, getTypeConverter, getValidator, initBeanPropertyAccess, initDirectFieldAccess, isAllowed, isAutoGrowNestedPaths, isIgnoreInvalidFields, isIgnoreUnknownFields, registerCustomEditor, registerCustomEditor, setAllowedFields, setAutoGrowNestedPaths, setBindingErrorProcessor, setConversionService, setDisallowedFields, setExtractOldValueForEditor, setIgnoreInvalidFields, setIgnoreUnknownFields, setMessageCodesResolver, setRequiredFields, setValidator, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bean

protected BeanWrapper bean

GROOVY_DISALLOWED

public static final String[] GROOVY_DISALLOWED

DOMAINCLASS_DISALLOWED

public static final String[] DOMAINCLASS_DISALLOWED

GROOVY_DOMAINCLASS_DISALLOWED

public static final String[] GROOVY_DOMAINCLASS_DISALLOWED

NULL_ASSOCIATION

public static final String NULL_ASSOCIATION
See Also:
Constant Field Values

DEFAULT_DATE_FORMAT

public static final String DEFAULT_DATE_FORMAT
See Also:
Constant Field Values
Constructor Detail

GrailsDataBinder

public GrailsDataBinder(Object target,
                        String objectName)
Create a new GrailsDataBinder instance.

Parameters:
target - target object to bind onto
objectName - objectName of the target object
Method Detail

createBinder

public static GrailsDataBinder createBinder(Object target,
                                            String objectName,
                                            HttpServletRequest request)
Utility method for creating a GrailsDataBinder instance

Parameters:
target - The target object to bind to
objectName - The name of the object
request - A request instance
Returns:
A GrailsDataBinder instance

registerCustomEditors

public static void registerCustomEditors(PropertyEditorRegistry registry,
                                         Locale locale)
Registers all known

Parameters:
registry -
locale -

createBinder

public static GrailsDataBinder createBinder(Object target,
                                            String objectName)
Utility method for creating a GrailsDataBinder instance

Parameters:
target - The target object to bind to
objectName - The name of the object
Returns:
A GrailsDataBinder instance

bind

public void bind(PropertyValues propertyValues)
Overrides:
bind in class DataBinder

bind

public void bind(org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap params)
Binds from a GrailsParameterMap object

Parameters:
params - The GrailsParameterMap object

bind

public void bind(org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap params,
                 String prefix)

bind

public void bind(PropertyValues propertyValues,
                 String prefix)

bind

public void bind(ServletRequest request)
Overrides:
bind in class ServletRequestDataBinder

bind

public void bind(ServletRequest request,
                 String prefix)

doBind

protected void doBind(MutablePropertyValues mpvs)
Overrides:
doBind in class WebDataBinder

autoCreateIfPossible

protected void autoCreateIfPossible(MutablePropertyValues mpvs)
Method that auto-creates the a type if it is null and is possible to auto-create

Parameters:
mpvs - A MutablePropertyValues instance

bindAssociations

protected void bindAssociations(MutablePropertyValues mpvs)
Interrogates the specified properties looking for properites that represent associations to other classes (e.g., 'author.id'). If such a property is found, this method attempts to load the specified instance of the association (by ID) and set it on the target object.

Parameters:
mpvs - the MutablePropertyValues object holding the parameters from the request


Copyright (c) 2005-2009 The Grails project