Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD

## org.grails.databinding
[Java] Interface StructuredBindingEditor

    org.grails.databinding.StructuredBindingEditor
      org.grails.databinding.BindingHelper

All Superinterfaces:
  BindingHelper

    public interface StructuredBindingEditor
    extends BindingHelper

StructuredBindingEditors convert structured data in a Map into an object. Typically a structured editor will pull several values out of the Map that are necessary to initialize the state of the object.

    class Address {
        String state
        String city
    }
    class StructuredAddressBindingEditor implements StructuredBindingEditor {

        public Object getPropertyValue(Object obj, String propertyName, Map source) {
            def address = new Address()

            address.state = source[propertyName + '_someState']
            address.city = source[propertyName + '_someCity']

            address
        }
    }

    def binder = new SimpleDataBinder()
    binder.registerStructuredEditor Address, new StructuredAddressBindingEditor()
    def resident = new Resident()
    def bindingSource = [:]
    bindingSource.name = 'Scott'
    bindingSource.homeAddress_someCity = "Scott's Home City"
    bindingSource.homeAddress_someState = "Scott's Home State"
    bindingSource.workAddress_someState = "Scott's Work State"
    bindingSource.workAddress = 'struct'
    bindingSource.homeAddress = 'struct'

    binder.bind resident, bindingSource

    resident.name == 'Scott'
    resident.homeAddress
    assert resident.homeAddress.city == "Scott's Home City"
    assert resident.homeAddress.state == "Scott's Home State"
    assert resident.workAddress
    assert resident.workAddress.state == "Scott's Work State"
    assert resident.workAddress.city == null

Authors:
  Jeff Brown

See Also:
  SimpleDataBinder.registerStructuredEditor

Since:
  2.3

Method Summary
`java.lang.Object` | `getPropertyValue(java.lang.Object obj, java.lang.String propertyName, DataBindingSource source)` The value returned from this method will be bound to the property specified by propertyName.

Methods inherited from interface BindingHelper
getPropertyValue

Method Detail

### getPropertyValue

    public java.lang.Object getPropertyValue(java.lang.Object obj, java.lang.String propertyName, DataBindingSource source)

  The value returned from this method will be bound to the property specified by propertyName.
  Parameters:
    `obj` - The object that data binding is being applied to
    `propertyName` - The name of the property data binding is being applied to
    `source` - The source containing all of the values being bound to this object
  Returns:
    The value which should be bound to propertyName

Groovy Documentation