Package grails.web.databinding
Class DataBindingUtils
- java.lang.Object
-
- grails.web.databinding.DataBindingUtils
-
public class DataBindingUtils extends java.lang.ObjectUtility methods to perform data binding from Grails objects.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDATA_BINDER_BEAN_NAME
-
Constructor Summary
Constructors Constructor Description DataBindingUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassignBidirectionalAssociations(java.lang.Object object, java.util.Map source, org.grails.datastore.mapping.model.PersistentEntity persistentEntity)Associations both sides of any bidirectional relationships found in the object and source map to bindstatic org.springframework.validation.BindingResultbindObjectToDomainInstance(org.grails.datastore.mapping.model.PersistentEntity entity, java.lang.Object object, java.lang.Object source)Binds the given source object to the given target object performing type conversion if necessarystatic org.springframework.validation.BindingResultbindObjectToDomainInstance(org.grails.datastore.mapping.model.PersistentEntity entity, java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)Binds the given source object to the given target object performing type conversion if necessarystatic org.springframework.validation.BindingResultbindObjectToInstance(java.lang.Object object, java.lang.Object source)Binds the given source object to the given target object performing type conversion if necessarystatic org.springframework.validation.BindingResultbindObjectToInstance(java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)Binds the given source object to the given target object performing type conversion if necessarystatic <T> voidbindToCollection(java.lang.Class<T> targetType, java.util.Collection<T> collectionToPopulate, grails.databinding.CollectionDataBindingSource collectionBindingSource)For each DataBindingSource provided by collectionBindingSource a new instance of targetType is created, data binding is imposed on that instance with the DataBindingSource and the instance is added to the end of collectionToPopulatestatic <T> voidbindToCollection(java.lang.Class<T> targetType, java.util.Collection<T> collectionToPopulate, javax.servlet.ServletRequest request)static java.util.MapconvertPotentialGStrings(java.util.Map<java.lang.Object,java.lang.Object> args)static grails.databinding.CollectionDataBindingSourcecreateCollectionDataBindingSource(grails.core.GrailsApplication grailsApplication, java.lang.Class bindingTargetType, java.lang.Object bindingSource)static grails.databinding.DataBindingSourcecreateDataBindingSource(grails.core.GrailsApplication grailsApplication, java.lang.Class bindingTargetType, java.lang.Object bindingSource)protected static java.util.ListgetBindingIncludeList(java.lang.Object object)static org.grails.web.databinding.bindingsource.DataBindingSourceRegistrygetDataBindingSourceRegistry(grails.core.GrailsApplication grailsApplication)protected static java.lang.String[]getMessageCodes(java.lang.String messageCode, java.lang.Class objectType)static grails.web.mime.MimeTypegetMimeType(grails.core.GrailsApplication grailsApplication, java.lang.Object bindingSource)static grails.web.mime.MimeTypeResolvergetMimeTypeResolver(grails.core.GrailsApplication grailsApplication)static grails.web.mime.MimeTyperesolveMimeType(java.lang.Object bindingSource, grails.web.mime.MimeTypeResolver mimeTypeResolver)
-
-
-
Field Detail
-
DATA_BINDER_BEAN_NAME
public static final java.lang.String DATA_BINDER_BEAN_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
assignBidirectionalAssociations
public static void assignBidirectionalAssociations(java.lang.Object object, java.util.Map source, org.grails.datastore.mapping.model.PersistentEntity persistentEntity)Associations both sides of any bidirectional relationships found in the object and source map to bind- Parameters:
object- The objectsource- The source mappersistentEntity- The PersistentEntity for the object
-
bindObjectToInstance
public static org.springframework.validation.BindingResult bindObjectToInstance(java.lang.Object object, java.lang.Object source)Binds the given source object to the given target object performing type conversion if necessary- Parameters:
object- The object to bind tosource- The source object- Returns:
- A BindingResult if there were errors or null if it was successful
-
getBindingIncludeList
protected static java.util.List getBindingIncludeList(java.lang.Object object)
-
bindObjectToDomainInstance
public static org.springframework.validation.BindingResult bindObjectToDomainInstance(org.grails.datastore.mapping.model.PersistentEntity entity, java.lang.Object object, java.lang.Object source)Binds the given source object to the given target object performing type conversion if necessary- Parameters:
entity- The PersistentEntity instanceobject- The object to bind tosource- The source object- Returns:
- A BindingResult if there were errors or null if it was successful
- See Also:
PersistentEntity
-
bindToCollection
public static <T> void bindToCollection(java.lang.Class<T> targetType, java.util.Collection<T> collectionToPopulate, grails.databinding.CollectionDataBindingSource collectionBindingSource) throws java.lang.InstantiationException, java.lang.IllegalAccessExceptionFor each DataBindingSource provided by collectionBindingSource a new instance of targetType is created, data binding is imposed on that instance with the DataBindingSource and the instance is added to the end of collectionToPopulate- Parameters:
targetType- The type of objects to create, must be a concrete classcollectionToPopulate- A collection to populate with new instances of targetTypecollectionBindingSource- A CollectionDataBindingSource- Throws:
java.lang.InstantiationExceptionjava.lang.IllegalAccessException- Since:
- 2.3
-
bindToCollection
public static <T> void bindToCollection(java.lang.Class<T> targetType, java.util.Collection<T> collectionToPopulate, javax.servlet.ServletRequest request) throws java.lang.InstantiationException, java.lang.IllegalAccessException- Throws:
java.lang.InstantiationExceptionjava.lang.IllegalAccessException
-
bindObjectToInstance
public static org.springframework.validation.BindingResult bindObjectToInstance(java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)Binds the given source object to the given target object performing type conversion if necessary- Parameters:
object- The object to bind tosource- The source objectinclude- The list of properties to includeexclude- The list of properties to excludefilter- The prefix to filter by- Returns:
- A BindingResult if there were errors or null if it was successful
-
bindObjectToDomainInstance
public static org.springframework.validation.BindingResult bindObjectToDomainInstance(org.grails.datastore.mapping.model.PersistentEntity entity, java.lang.Object object, java.lang.Object source, java.util.List include, java.util.List exclude, java.lang.String filter)Binds the given source object to the given target object performing type conversion if necessary- Parameters:
entity- The PersistentEntity instanceobject- The object to bind tosource- The source objectinclude- The list of properties to includeexclude- The list of properties to excludefilter- The prefix to filter by- Returns:
- A BindingResult if there were errors or null if it was successful
- See Also:
PersistentEntity
-
getMessageCodes
protected static java.lang.String[] getMessageCodes(java.lang.String messageCode, java.lang.Class objectType)
-
getDataBindingSourceRegistry
public static org.grails.web.databinding.bindingsource.DataBindingSourceRegistry getDataBindingSourceRegistry(grails.core.GrailsApplication grailsApplication)
-
createDataBindingSource
public static grails.databinding.DataBindingSource createDataBindingSource(grails.core.GrailsApplication grailsApplication, java.lang.Class bindingTargetType, java.lang.Object bindingSource)
-
createCollectionDataBindingSource
public static grails.databinding.CollectionDataBindingSource createCollectionDataBindingSource(grails.core.GrailsApplication grailsApplication, java.lang.Class bindingTargetType, java.lang.Object bindingSource)
-
getMimeType
public static grails.web.mime.MimeType getMimeType(grails.core.GrailsApplication grailsApplication, java.lang.Object bindingSource)
-
getMimeTypeResolver
public static grails.web.mime.MimeTypeResolver getMimeTypeResolver(grails.core.GrailsApplication grailsApplication)
-
resolveMimeType
public static grails.web.mime.MimeType resolveMimeType(java.lang.Object bindingSource, grails.web.mime.MimeTypeResolver mimeTypeResolver)
-
convertPotentialGStrings
public static java.util.Map convertPotentialGStrings(java.util.Map<java.lang.Object,java.lang.Object> args)
-
-