@SuppressWarnings(['CatchException']) @CompileStatic class EntityMapBinder extends GrailsWebDataBinder
Faster data binder for PersistentEntity.persistentProperties. Uses the persistentProperties to assign values from the Map Explicitly checks and converts most common property types eg (numbers and dates). Otherwise fallbacks to value converters.
Modifiers | Name | Description |
---|---|---|
protected static Map<Class, List> |
CLASS_TO_BINDING_INCLUDE_LIST |
Fields inherited from class | Fields |
---|---|
class GrailsWebDataBinder |
__$stMC, __$stMC, DEFAULT_DATE_FORMAT |
class SimpleDataBinder |
__$stMC, DEFAULT_DATE_FORMAT |
Type | Name and description |
---|---|
static Map<Class, List> |
EXPLICIT_BINDING_LIST A map that holds lists of properties which should be bound manually by a binder. |
Constructor and description |
---|
EntityMapBinder
() |
EntityMapBinder
(GrailsApplication grailsApplication) |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
bind(Object obj, DataBindingSource source) Binds data from a map on target object. |
|
void |
bind(Object obj, DataBindingSource source, DataBindingListener listener) Binds data from a map on target object. |
|
void |
bind(Object object, DataBindingSource source, String filter, List whiteList, List blackList, DataBindingListener listener) Binds data from a map on target object. |
|
void |
bind(Map args = [:], Object target, Map<String, Object> source) Binds data from a map on target object. |
|
void |
bindAssociation(Object target, Object value, Association association, DataBindingListener listener = null, Object errors = null) Binds a given association to the target entity. |
|
protected void |
doBind(Object object, DataBindingSource source, String filter, List whiteList, List blackList, DataBindingListener listener, Object errors) |
|
void |
fastBind(Object target, DataBindingSource source, List whiteList = null, DataBindingListener listener = null, Object errors = null) Binds properties which specified in a white list on the given entity. |
|
static List |
getBindingIncludeList(Object object) Sets up a list of properties which can be binded to a given domain entity. |
|
protected def |
getPersistentInstance(Class<?> type, Object id) |
|
static boolean |
isExplicitBind(Object target, String name) Checks if a given association is explicitly marked as bindable and should be binded in any case. |
|
void |
setProp(Object target, DataBindingSource source, PersistentProperty prop, DataBindingListener listener = null, Object errors = null) Sets a value to a specified target's property. |
Binds data from a map on target object.
obj
- The target object to bindsource
- The data binding sourceBinds data from a map on target object.
obj
- The target object to bindsource
- The data binding sourcelistener
- DataBindingListenerBinds data from a map on target object.
obj
- The target object to bindsource
- The data binding sourcefilter
- Only properties beginning with filter will be included in the data binding.whiteList
- A list of property names to be included during this
data binding. All other properties represented in the binding source
will be ignoredblackList
- A list of properties names to be excluded during
this data binding.listener
- DataBindingListenerBinds data from a map on target object.
args
- An optional map of options. supports two boolean options
target
- The target object to bindsource
- The data binding sourceBinds a given association to the target entity. It checks if the given value contains an id and loads the associated entity. In case the id is not specified, this method checks if the given association belongs to the target entity. In case it does, or the it has the explicitly specified 'bindable:true' constraint, then a new instance is created for the association.
target
- a target entity to bind an association tovalue
- an association's valueassociation
- an association propertylistener
- DataBindingListenerBinds properties which specified in a white list on the given entity. In case the white list is empty method takes the list of persistent properties and iterates on them.
target
- a target entitysource
- a data binding source which contains property valueswhiteList
- a list which contains properties for bindinglistener
- DataBindingListener Sets up a list of properties which can be binded to a given domain entity.
Puts the created list to $CLASS_TO_BINDING_INCLUDE_LIST
map,
which caches such lists for domain classes.
The method also checks if a property has an explicitly defined 'bindable:true' constraint.
In case the constraint is present, the property name is added to EXPLICIT_BINDING_LIST
.
object
- an entity for which the list should be createdChecks if a given association is explicitly marked as bindable and should be binded in any case.
target
- an entity which contains an associationname
- a name of an association to check if it should be bindedSets a value to a specified target's property.
target
- a target entitysource
- a data binding source which contains property valuesprop
- a persistent property which should be filled with the valuelistener
- DataBindingListenerGroovy Documentation