@ -29,11 +29,11 @@ import org.springframework.context.MessageSource;
@@ -29,11 +29,11 @@ import org.springframework.context.MessageSource;
import org.springframework.core.GenericCollectionTypeResolver ;
import org.springframework.core.convert.TypeConverter ;
import org.springframework.core.convert.support.DefaultTypeConverter ;
import org.springframework.ui.binding.Binding ;
import org.springframework.ui.binding.BindingFactory ;
import org.springframework.ui.binding.FieldModel ;
import org.springframework.ui.binding.FieldNotFoundException ;
import org.springframework.ui.binding.PresentationModel ;
import org.springframework.ui.binding.binder.Binder ;
import org.springframework.ui.binding.binder.BindingResult ;
import org.springframework.ui.binding.config.BindingRuleConfiguration ;
import org.springframework.ui.binding.config.FieldModelConfiguration ;
import org.springframework.ui.binding.config.Condition ;
import org.springframework.ui.format.Formatter ;
import org.springframework.util.Assert ;
@ -42,15 +42,16 @@ import org.springframework.util.Assert;
@@ -42,15 +42,16 @@ import org.springframework.util.Assert;
* A generic { @link Binder binder } suitable for use in most environments .
* @author Keith Donald
* @since 3 . 0
* @see # setFormatterRegistry ( FormatterRegistry )
* @see # setMessageSource ( MessageSource )
* @see # setTypeConverter ( TypeConverter )
* @see # bind ( Map )
* /
public class GenericBindingFactory implements BindingFactory {
public class DefaultPresentationModel implements PresentationModel {
private Object model ;
private Object do mainM odel;
private Map < String , GenericBindingRule > binding Rules;
private Map < String , PropertyFieldModelRule > fieldModel Rules;
private FormatterRegistry formatterRegistry ;
@ -59,19 +60,19 @@ public class GenericBindingFactory implements BindingFactory {
@@ -59,19 +60,19 @@ public class GenericBindingFactory implements BindingFactory {
private MessageSource messageSource ;
/ * *
* Creates a new binder for the model object .
* @param model the model object containing properties this binder will bind to
* Creates a new presentation model for the domain model .
* @param do mainM odel the domain model object
* /
public GenericBindingFactory ( Object model ) {
Assert . notNull ( model , "The model to bind to is required" ) ;
this . model = model ;
binding Rules = new HashMap < String , GenericBinding Rule> ( ) ;
public DefaultPresentationModel ( Object do mainM odel) {
Assert . notNull ( do mainM odel, "The domain model to bind to is required" ) ;
this . do mainM odel = do mainM odel;
fieldModel Rules = new HashMap < String , PropertyFieldModel Rule> ( ) ;
formatterRegistry = new GenericFormatterRegistry ( ) ;
typeConverter = new DefaultTypeConverter ( ) ;
}
/ * *
* Configures the registry of Formatters to query when no explicit Formatter has been registered for a Binding .
* Configures the registry of Formatters to query when no explicit Formatter has been registered for a field .
* Allows Formatters to be applied by property type and by property annotation .
* @param registry the formatter registry
* /
@ -81,7 +82,7 @@ public class GenericBindingFactory implements BindingFactory {
@@ -81,7 +82,7 @@ public class GenericBindingFactory implements BindingFactory {
}
/ * *
* Configure the MessageSource that resolves localized { @link BindingResult } alert messages .
* Configure the MessageSource that resolves localized UI alert messages .
* @param messageSource the message source
* /
public void setMessageSource ( MessageSource messageSource ) {
@ -90,10 +91,11 @@ public class GenericBindingFactory implements BindingFactory {
@@ -90,10 +91,11 @@ public class GenericBindingFactory implements BindingFactory {
}
/ * *
* Configure the TypeConverter that converts values as required by Binding setValue and getValue attempts .
* For a setValue attempt , the TypeConverter will be asked to perform a conversion if the value parsed by the Binding ' s Formatter is not assignable to the target property type .
* For a getValue attempt , the TypeConverter will be asked to perform a conversion if the property type does not match the type T required by the Binding ' s Formatter .
* @param typeConverter the type converter used by the binding system , which is based on Spring EL
* Configure the TypeConverter that converts values as required by the binding system .
* For a { @link FieldModel # applySubmittedValue ( Object ) applySubmittedValue call } , this TypeConverter will be asked to perform a conversion if the value parsed by the field ' s Formatter is not assignable to the target value type .
* For a { @link FieldModel # getRenderValue ( ) getRenderValue call } , this TypeConverter will be asked to perform a conversion if the value type does not match the type T required by the field ' s Formatter .
* For a { @link FieldModel # getMapValue ( Object ) getMapValue call } this TypeConverter will be asked to convert the Map key to the type required if there is no keyFormatter registered for the field .
* @param typeConverter the type converter used by the binding system
* /
public void setTypeConverter ( TypeConverter typeConverter ) {
Assert . notNull ( typeConverter , "The TypeConverter is required" ) ;
@ -101,57 +103,57 @@ public class GenericBindingFactory implements BindingFactory {
@@ -101,57 +103,57 @@ public class GenericBindingFactory implements BindingFactory {
}
/ * *
* Add a new binding r ule for the property at the path specified .
* Add a a new FieldModelR ule for the property at the path specified .
* @param propertyPath binding rule property path in format prop . nestedProp
* @return a builder for the binding rule
* /
public BindingRuleConfiguration bindingRule ( String propertyPath ) {
Property Path path = new Property Path( propertyPath ) ;
GenericBinding Rule rule = getBinding Rule ( path . getFirstElement ( ) . getValue ( ) ) ;
for ( Property PathElement element : path . getNestedElements ( ) ) {
rule = rule . getBinding Rule ( element . getValue ( ) ) ;
public FieldModelConfiguration field ( String propertyPath ) {
Field Path path = new Field Path( propertyPath ) ;
PropertyFieldModel Rule rule = getRule ( path . getFirstElement ( ) . getValue ( ) ) ;
for ( Field PathElement element : path . getNestedElements ( ) ) {
rule = rule . getNested Rule ( element . getValue ( ) ) ;
}
return rule ;
}
// implementing Binder
public Object getModel ( ) {
return model ;
public Object getDomainModel ( ) {
return domainModel ;
}
public Binding getBinding ( String property ) {
PropertyPath path = new PropertyPath ( property ) ;
Binding binding = getBindingRule ( path . getFirstElement ( ) . getValue ( ) ) . getBinding ( model ) ;
for ( PropertyPathElement element : path . getNestedElements ( ) ) {
// implementing PresentationModel
public FieldModel getFieldModel ( String fieldName ) {
FieldPath path = new FieldPath ( fieldName ) ;
FieldModel field = getRule ( path . getFirstElement ( ) . getValue ( ) ) . getFieldModel ( domainModel ) ;
for ( FieldPathElement element : path . getNestedElements ( ) ) {
if ( element . isIndex ( ) ) {
if ( binding . isMap ( ) ) {
binding = binding . getMapValueBinding ( element . getValue ( ) ) ;
} else if ( binding . isList ( ) ) {
binding = binding . getListElementBinding ( element . getIntValue ( ) ) ;
if ( field . isMap ( ) ) {
field = field . getMapValue ( element . getValue ( ) ) ;
} else if ( field . isList ( ) ) {
field = field . getListElement ( element . getIntValue ( ) ) ;
} else {
throw new IllegalArgumentException ( "Attempted to index a property that is not a List or Map" ) ;
throw new IllegalArgumentException ( "Attempted to index a field that is not a List, Array, or a Map" ) ;
}
} else {
binding = binding . getNestedBinding ( element . getValue ( ) ) ;
field = field . getNested ( element . getValue ( ) ) ;
}
}
return binding ;
return field ;
}
private GenericBindingRule getBindingRule ( String property ) {
GenericBindingRule rule = binding Rules. get ( property ) ;
private PropertyFieldModelRule getRule ( String fieldName ) {
PropertyFieldModelRule rule = fieldModel Rules. get ( fieldName ) ;
if ( rule = = null ) {
rule = new GenericBindingRule ( property , m odel. getClass ( ) ) ;
binding Rules. put ( property , rule ) ;
rule = new PropertyFieldModelRule ( fieldName , domainM odel. getClass ( ) ) ;
fieldModel Rules. put ( fieldName , rule ) ;
}
return rule ;
}
@SuppressWarnings ( "unchecked" )
class GenericBindingRule implements BindingRuleConfiguration , Binding Context {
class PropertyFieldModelRule implements FieldModelConfiguration , FieldModel Context {
private Class < ? > modelClass ;
private Class < ? > do mainM odelClass;
private PropertyDescriptor property ;
@ -167,20 +169,20 @@ public class GenericBindingFactory implements BindingFactory {
@@ -167,20 +169,20 @@ public class GenericBindingFactory implements BindingFactory {
private Condition visibleCondition = Condition . ALWAYS_TRUE ;
private Map < String , GenericBindingRule > nestedBinding Rules;
private Map < String , PropertyFieldModelRule > nestedFieldModel Rules;
private Binding binding ;
private FieldModel fieldModel ;
private Map < Integer , Binding > listElementBinding s ;
private Map < Integer , FieldModel > listElements ;
private Map < Object , Binding > mapValueBinding s ;
private Map < Object , FieldModel > mapValues ;
public GenericBinding Rule( String property , Class modelClass ) {
this . modelClass = modelClass ;
public PropertyFieldModel Rule( String property , Class do mainM odelClass) {
this . do mainM odelClass = do mainM odelClass;
this . property = findPropertyDescriptor ( property ) ;
}
// implementing Binding Context
// implementing FieldModel Context
public MessageSource getMessageSource ( ) {
return messageSource ;
@ -226,84 +228,103 @@ public class GenericBindingFactory implements BindingFactory {
@@ -226,84 +228,103 @@ public class GenericBindingFactory implements BindingFactory {
return visibleCondition ;
}
public Binding getNestedBinding ( String property ) {
public String getLabel ( ) {
return property . getName ( ) ;
}
public FieldModel getNested ( String fieldName ) {
createValueIfNecessary ( ) ;
return getBindingRule ( property , binding . getValueType ( ) ) . getBinding ( binding . getValue ( ) ) ;
return getNestedRule ( fieldName , fieldModel . getValueType ( ) ) . getFieldModel ( fieldModel . getValue ( ) ) ;
}
public Binding getListElementBinding ( int index ) {
if ( listElementBindings = = null ) {
listElementBindings = new HashMap < Integer , Binding > ( ) ;
public FieldModel getListElement ( int index ) {
// TODO array support
if ( listElements = = null ) {
listElements = new HashMap < Integer , FieldModel > ( ) ;
}
growListIfNecessary ( index ) ;
Binding binding = listElementBinding s . get ( index ) ;
if ( binding = = null ) {
BindingContext bindingC ontext = new ListElementBinding Context ( index , this ) ;
ValueModel valueModel = new ListElementValueModel ( index , getElementType ( ) , ( List ) this . binding . getValue ( ) ) ;
binding = new GenericBinding ( valueModel , bindingC ontext) ;
listElementBinding s . put ( index , binding ) ;
FieldModel field = listElements . get ( index ) ;
if ( field = = null ) {
FieldModelContext c ontext = new ListElementContext ( index , this ) ;
ValueModel valueModel = new ListElementValueModel ( index , getElementType ( ) , ( List ) fieldModel . getValue ( ) ) ;
field = new DefaultFieldModel ( valueModel , c ontext) ;
listElements . put ( index , field ) ;
}
return binding ;
return field ;
}
public Binding getMapValueBinding ( Object key ) {
if ( mapValueBinding s = = null ) {
mapValueBinding s = new HashMap < Object , Binding > ( ) ;
public FieldModel getMapValue ( Object key ) {
if ( mapValues = = null ) {
mapValues = new HashMap < Object , FieldModel > ( ) ;
}
createMapValueIfNecessary ( ) ;
Binding binding = mapValueBinding s . get ( key ) ;
if ( binding = = null ) {
BindingContext bindingC ontext = new MapValueBinding Context ( key , this ) ;
ValueModel valueModel = new MapValueValueModel ( key , getElementType ( ) , ( Map ) this . binding . getValue ( ) , bindingC ontext) ;
binding = new GenericBinding ( valueModel , bindingC ontext) ;
mapValueBinding s . put ( key , binding ) ;
FieldModel field = mapValues . get ( key ) ;
if ( field = = null ) {
FieldModelContext c ontext = new MapValueContext ( key , this ) ;
ValueModel valueModel = new MapValueValueModel ( key , getElementType ( ) , ( Map ) fieldModel . getValue ( ) , c ontext) ;
field = new DefaultFieldModel ( valueModel , c ontext) ;
mapValues . put ( key , field ) ;
}
return binding ;
}
public String getLabel ( ) {
return property . getName ( ) ;
return field ;
}
// implementing BindingRule Configuration
// implementing FieldModelConfiguration
public BindingRule Configuration formatWith ( Formatter < ? > formatter ) {
public FieldModel Configuration formatWith ( Formatter < ? > formatter ) {
this . formatter = formatter ;
return this ;
}
public BindingRule Configuration formatElementsWith ( Formatter < ? > formatter ) {
if ( ! List . class . isAssignableFrom ( modelClass ) | | modelClass . isArray ( ) ) {
public FieldModel Configuration formatElementsWith ( Formatter < ? > formatter ) {
if ( ! List . class . isAssignableFrom ( do mainM odelClass) | | do mainM odelClass. isArray ( ) ) {
throw new IllegalStateException (
"Bound property is not a List or an a rray; cannot set a element formatter" ) ;
"Field is not a List or an A rray; cannot set a element formatter" ) ;
}
elementFormatter = formatter ;
return this ;
}
public BindingRule Configuration formatKeysWith ( Formatter < ? > formatter ) {
if ( ! Map . class . isAssignableFrom ( modelClass ) ) {
throw new IllegalStateException ( "Bound property is not a Map; cannot set a key formatter" ) ;
public FieldModel Configuration formatKeysWith ( Formatter < ? > formatter ) {
if ( ! Map . class . isAssignableFrom ( do mainM odelClass) ) {
throw new IllegalStateException ( "Field is not a Map; cannot set a key formatter" ) ;
}
keyFormatter = formatter ;
return this ;
}
public BindingRule Configuration editableWhen ( Condition condition ) {
public FieldModel Configuration editableWhen ( Condition condition ) {
editableCondition = condition ;
return this ;
}
public BindingRule Configuration enabledWhen ( Condition condition ) {
public FieldModel Configuration enabledWhen ( Condition condition ) {
enabledCondition = condition ;
return this ;
}
public BindingRule Configuration visibleWhen ( Condition condition ) {
public FieldModel Configuration visibleWhen ( Condition condition ) {
visibleCondition = condition ;
return this ;
}
// package private helpers
PropertyFieldModelRule getNestedRule ( String propertyName ) {
return getNestedRule ( propertyName , this . property . getPropertyType ( ) ) ;
}
PropertyFieldModelRule getNestedRule ( String propertyName , Class < ? > domainModelClass ) {
if ( nestedFieldModelRules = = null ) {
nestedFieldModelRules = new HashMap < String , PropertyFieldModelRule > ( ) ;
}
PropertyFieldModelRule rule = nestedFieldModelRules . get ( propertyName ) ;
if ( rule = = null ) {
rule = new PropertyFieldModelRule ( propertyName , domainModelClass ) ;
nestedFieldModelRules . put ( propertyName , rule ) ;
}
return rule ;
}
// internal helpers
private Class < ? > getElementType ( ) {
@ -318,40 +339,22 @@ public class GenericBindingFactory implements BindingFactory {
@@ -318,40 +339,22 @@ public class GenericBindingFactory implements BindingFactory {
return GenericCollectionTypeResolver . getMapKeyReturnType ( property . getReadMethod ( ) ) ;
}
GenericBindingRule getBindingRule ( String property ) {
return getBindingRule ( property , this . property . getPropertyType ( ) ) ;
}
GenericBindingRule getBindingRule ( String property , Class < ? > modelClass ) {
if ( nestedBindingRules = = null ) {
nestedBindingRules = new HashMap < String , GenericBindingRule > ( ) ;
FieldModel getFieldModel ( Object domainObject ) {
if ( fieldModel = = null ) {
PropertyValueModel valueModel = new PropertyValueModel ( property , domainObject ) ;
fieldModel = new DefaultFieldModel ( valueModel , this ) ;
}
GenericBindingRule rule = nestedBindingRules . get ( property ) ;
if ( rule = = null ) {
rule = new GenericBindingRule ( property , modelClass ) ;
nestedBindingRules . put ( property , rule ) ;
}
return rule ;
}
// internal helpers
Binding getBinding ( Object model ) {
if ( binding = = null ) {
PropertyValueModel valueModel = new PropertyValueModel ( property , model ) ;
binding = new GenericBinding ( valueModel , this ) ;
}
return binding ;
return fieldModel ;
}
private PropertyDescriptor findPropertyDescriptor ( String property ) {
PropertyDescriptor [ ] propDescs = getBeanInfo ( modelClass ) . getPropertyDescriptors ( ) ;
PropertyDescriptor [ ] propDescs = getBeanInfo ( domainModelClass ) . getPropertyDescriptors ( ) ;
for ( PropertyDescriptor propDesc : propDescs ) {
if ( propDesc . getName ( ) . equals ( property ) ) {
return propDesc ;
}
}
throw new Property NotFoundException( property , modelClass ) ;
throw new FieldNotFoundException ( property ) ;
}
private BeanInfo getBeanInfo ( Class < ? > clazz ) {
@ -363,30 +366,30 @@ public class GenericBindingFactory implements BindingFactory {
@@ -363,30 +366,30 @@ public class GenericBindingFactory implements BindingFactory {
}
private void createValueIfNecessary ( ) {
Object value = binding . getValue ( ) ;
Object value = fieldModel . getValue ( ) ;
if ( value = = null ) {
value = newValue ( binding . getValueType ( ) ) ;
binding . applySource Value( value ) ;
binding . commit ( ) ;
value = newValue ( fieldModel . getValueType ( ) ) ;
fieldModel . applySubmitted Value( value ) ;
fieldModel . commit ( ) ;
}
}
private void createMapValueIfNecessary ( ) {
Object value = binding . getValue ( ) ;
Object value = fieldModel . getValue ( ) ;
if ( value = = null ) {
value = newMapValue ( binding . getValueType ( ) ) ;
binding . applySource Value( value ) ;
binding . commit ( ) ;
value = newMapValue ( fieldModel . getValueType ( ) ) ;
fieldModel . applySubmitted Value( value ) ;
fieldModel . commit ( ) ;
}
}
private void growListIfNecessary ( int index ) {
List list = ( List ) binding . getValue ( ) ;
List list = ( List ) fieldModel . getValue ( ) ;
if ( list = = null ) {
list = newListValue ( binding . getValueType ( ) ) ;
binding . applySource Value( list ) ;
binding . commit ( ) ;
list = ( List ) binding . getValue ( ) ;
list = newListValue ( fieldModel . getValueType ( ) ) ;
fieldModel . applySubmitted Value( list ) ;
fieldModel . commit ( ) ;
list = ( List ) fieldModel . getValue ( ) ;
}
if ( index > = list . size ( ) ) {
for ( int i = list . size ( ) ; i < = index ; i + + ) {
@ -423,15 +426,15 @@ public class GenericBindingFactory implements BindingFactory {
@@ -423,15 +426,15 @@ public class GenericBindingFactory implements BindingFactory {
}
private static class ListElementBinding Context implements Binding Context {
private static class ListElementContext implements FieldModel Context {
private int index ;
private GenericBinding Rule listBindingContext ;
private PropertyFieldModel Rule listBindingContext ;
final Map < String , Binding > nestedBindings = new HashMap < String , Binding > ( ) ;
final Map < String , FieldModel > nestedBindings = new HashMap < String , FieldModel > ( ) ;
public ListElementBinding Context ( int index , GenericBinding Rule listBindingContext ) {
public ListElementContext ( int index , PropertyFieldModel Rule listBindingContext ) {
this . index = index ;
this . listBindingContext = listBindingContext ;
}
@ -444,22 +447,6 @@ public class GenericBindingFactory implements BindingFactory {
@@ -444,22 +447,6 @@ public class GenericBindingFactory implements BindingFactory {
return listBindingContext . getTypeConverter ( ) ;
}
public Binding getNestedBinding ( String property ) {
Object model = ( ( List < ? > ) listBindingContext . binding . getValue ( ) ) . get ( index ) ;
Class < ? > elementType = listBindingContext . getElementType ( ) ;
if ( elementType = = null ) {
elementType = model . getClass ( ) ;
}
GenericBindingRule rule = listBindingContext . getBindingRule ( property , elementType ) ;
Binding binding = nestedBindings . get ( property ) ;
if ( binding = = null ) {
PropertyValueModel valueModel = new PropertyValueModel ( rule . property , model ) ;
binding = new GenericBinding ( valueModel , rule ) ;
nestedBindings . put ( property , binding ) ;
}
return binding ;
}
@SuppressWarnings ( "unchecked" )
public Formatter getFormatter ( ) {
return listBindingContext . getElementFormatter ( ) ;
@ -467,11 +454,13 @@ public class GenericBindingFactory implements BindingFactory {
@@ -467,11 +454,13 @@ public class GenericBindingFactory implements BindingFactory {
@SuppressWarnings ( "unchecked" )
public Formatter getElementFormatter ( ) {
// TODO multi-dimensional support
return null ;
}
@SuppressWarnings ( "unchecked" )
public Formatter getKeyFormatter ( ) {
// TODO multi-dimensional support
return null ;
}
@ -487,95 +476,116 @@ public class GenericBindingFactory implements BindingFactory {
@@ -487,95 +476,116 @@ public class GenericBindingFactory implements BindingFactory {
return listBindingContext . getVisibleCondition ( ) ;
}
public Binding getListElementBinding ( int index ) {
throw new IllegalArgumentException ( "Not yet supported" ) ;
public String getLabel ( ) {
return listBindingContext . getLabel ( ) + "[" + index + "]" ;
}
public Binding getMapValueBinding ( Object key ) {
throw new IllegalArgumentException ( "Not yet supported" ) ;
public FieldModel getNested ( String property ) {
Object model = ( ( List < ? > ) listBindingContext . fieldModel . getValue ( ) ) . get ( index ) ;
Class < ? > elementType = listBindingContext . getElementType ( ) ;
if ( elementType = = null ) {
elementType = model . getClass ( ) ;
}
PropertyFieldModelRule rule = listBindingContext . getNestedRule ( property , elementType ) ;
FieldModel binding = nestedBindings . get ( property ) ;
if ( binding = = null ) {
PropertyValueModel valueModel = new PropertyValueModel ( rule . property , model ) ;
binding = new DefaultFieldModel ( valueModel , rule ) ;
nestedBindings . put ( property , binding ) ;
}
return binding ;
}
public String getLabel ( ) {
return listBindingContext . getLabel ( ) + "[" + index + "]" ;
public FieldModel getListElement ( int index ) {
// TODO multi-dimensional support
throw new IllegalArgumentException ( "Not yet supported" ) ;
}
public FieldModel getMapValue ( Object key ) {
// TODO multi-dimensional support
throw new IllegalArgumentException ( "Not yet supported" ) ;
}
} ;
private static class MapValueBindingContext implements BindingContext {
private static class MapValueContext implements FieldModel Context {
private Object key ;
private GenericBindingRule mapBinding Context;
private PropertyFieldModelRule map Context;
final Map < String , Binding > nestedBindings = new HashMap < String , Binding > ( ) ;
final Map < String , FieldModel > nestedBindings = new HashMap < String , FieldModel > ( ) ;
public MapValueBinding Context ( Object key , GenericBindingRule mapBinding Context) {
public MapValueContext ( Object key , PropertyFieldModelRule map Context) {
this . key = key ;
this . mapBinding Context = mapBinding Context ;
this . mapContext = mapContext ;
}
public MessageSource getMessageSource ( ) {
return mapBinding Context . getMessageSource ( ) ;
return mapContext . getMessageSource ( ) ;
}
public TypeConverter getTypeConverter ( ) {
return mapBindingContext . getTypeConverter ( ) ;
}
@SuppressWarnings ( "unchecked" )
public Binding getNestedBinding ( String property ) {
Object model = ( ( Map ) mapBindingContext . binding . getValue ( ) ) . get ( key ) ;
Class < ? > elementType = mapBindingContext . getElementType ( ) ;
if ( elementType = = null ) {
elementType = model . getClass ( ) ;
}
GenericBindingRule rule = mapBindingContext . getBindingRule ( property , elementType ) ;
Binding binding = nestedBindings . get ( property ) ;
if ( binding = = null ) {
PropertyValueModel valueModel = new PropertyValueModel ( rule . property , model ) ;
binding = new GenericBinding ( valueModel , rule ) ;
nestedBindings . put ( property , binding ) ;
}
return binding ;
return mapContext . getTypeConverter ( ) ;
}
@SuppressWarnings ( "unchecked" )
public Formatter getFormatter ( ) {
return mapBinding Context . getElementFormatter ( ) ;
return mapContext . getElementFormatter ( ) ;
}
@SuppressWarnings ( "unchecked" )
public Formatter getElementFormatter ( ) {
// TODO multi-dimensional support
return null ;
}
@SuppressWarnings ( "unchecked" )
public Formatter getKeyFormatter ( ) {
// TODO multi-dimensional support
return null ;
}
public Condition getEditableCondition ( ) {
return mapBinding Context . getEditableCondition ( ) ;
return mapContext . getEditableCondition ( ) ;
}
public Condition getEnabledCondition ( ) {
return mapBinding Context . getEnabledCondition ( ) ;
return mapContext . getEnabledCondition ( ) ;
}
public Condition getVisibleCondition ( ) {
return mapBindingContext . getVisibleCondition ( ) ;
return mapContext . getVisibleCondition ( ) ;
}
@SuppressWarnings ( "unchecked" )
public FieldModel getNested ( String property ) {
Object model = ( ( Map ) mapContext . fieldModel . getValue ( ) ) . get ( key ) ;
Class < ? > elementType = mapContext . getElementType ( ) ;
if ( elementType = = null ) {
elementType = model . getClass ( ) ;
}
PropertyFieldModelRule rule = mapContext . getNestedRule ( property , elementType ) ;
FieldModel binding = nestedBindings . get ( property ) ;
if ( binding = = null ) {
PropertyValueModel valueModel = new PropertyValueModel ( rule . property , model ) ;
binding = new DefaultFieldModel ( valueModel , rule ) ;
nestedBindings . put ( property , binding ) ;
}
return binding ;
}
public Binding getListElementBinding ( int index ) {
public FieldModel getListElement ( int index ) {
// TODO multi-dimensional support
throw new IllegalArgumentException ( "Not yet supported" ) ;
}
public Binding getMapValueBinding ( Object key ) {
public FieldModel getMapValue ( Object key ) {
// TODO multi-dimensional support
throw new IllegalArgumentException ( "Not yet supported" ) ;
}
public String getLabel ( ) {
return mapBindingContext . getLabel ( ) + "[" + key + "]" ;
return mapContext . getLabel ( ) + "[" + key + "]" ;
}
} ;