moved binding configuration to publis binder api
This commit is contained in:
parent
a8e8382034
commit
9be56a39b4
|
|
@ -21,6 +21,7 @@ import java.util.Map;
|
||||||
* Binds user-entered values to properties of a model object.
|
* Binds user-entered values to properties of a model object.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
|
* @see #addBinding(String)
|
||||||
* @see #getBinding(String)
|
* @see #getBinding(String)
|
||||||
* @see #bind(Map)
|
* @see #bind(Map)
|
||||||
*/
|
*/
|
||||||
|
|
@ -31,6 +32,26 @@ public interface Binder {
|
||||||
*/
|
*/
|
||||||
Object getModel();
|
Object getModel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a binding to a model property.
|
||||||
|
* The property may be a path to a member property like "name", or a nested property like "address.city" or "addresses.city".
|
||||||
|
* If the property path is nested and traverses a collection or Map, do not use indexes.
|
||||||
|
* The property path should express the model-class property structure like addresses.city, not an object structure like addresses[0].city.
|
||||||
|
* Examples:
|
||||||
|
* <pre>
|
||||||
|
* name - bind to property 'name'
|
||||||
|
* addresses - bind to property 'addresses', presumably a List<Address> e.g. allowing property expressions like addresses={ 12345 Macy Lane, 1977 Bel Aire Estates } and addresses[0]=12345 Macy Lane
|
||||||
|
* addresses.city - bind to property 'addresses.city', for all indexed addresses in the collection e.g. allowing property expressions like addresses[0].city=Melbourne
|
||||||
|
* address.city - bind to property 'address.city'
|
||||||
|
* favoriteFoodByFoodGroup - bind to property 'favoriteFoodByFoodGroup', presumably a Map<FoodGroup, Food>; e.g. allowing favoriteFoodByFoodGroup={ DAIRY=Milk, MEAT=Steak } and favoriteFoodByFoodGroup['DAIRY']=Milk
|
||||||
|
* favoriteFoodByFoodGroup.name - bind to property 'favoriteFoodByFoodGroup.name', for all keyed Foods in the map; e.g. allowing favoriteFoodByFoodGroup['DAIRY'].name=Milk
|
||||||
|
* </pre>
|
||||||
|
* @param propertyPath the model property path
|
||||||
|
* @return a BindingConfiguration object, allowing additional configuration of the newly added binding
|
||||||
|
* @throws IllegalArgumentException if no such property path exists on the model
|
||||||
|
*/
|
||||||
|
public BindingConfiguration addBinding(String propertyPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a binding to a model property..
|
* Get a binding to a model property..
|
||||||
* @param property the property path
|
* @param property the property path
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,13 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.ui.binding.support;
|
package org.springframework.ui.binding;
|
||||||
|
|
||||||
|
import org.springframework.ui.binding.support.GenericBinder;
|
||||||
import org.springframework.ui.format.Formatter;
|
import org.springframework.ui.format.Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A fluent interface for configuring a newly added binding to a property path.
|
* A fluent interface for configuring a newly added binding.
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
* @see GenericBinder#addBinding(String)
|
* @see GenericBinder#addBinding(String)
|
||||||
*/
|
*/
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.ui.binding.support;
|
package org.springframework.ui.binding.support;
|
||||||
|
|
||||||
|
import org.springframework.ui.binding.BindingConfiguration;
|
||||||
import org.springframework.ui.format.Formatter;
|
import org.springframework.ui.format.Formatter;
|
||||||
|
|
||||||
final class DefaultBindingConfiguration implements BindingConfiguration {
|
final class DefaultBindingConfiguration implements BindingConfiguration {
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import org.springframework.ui.alert.Alert;
|
||||||
import org.springframework.ui.alert.Severity;
|
import org.springframework.ui.alert.Severity;
|
||||||
import org.springframework.ui.binding.Binder;
|
import org.springframework.ui.binding.Binder;
|
||||||
import org.springframework.ui.binding.Binding;
|
import org.springframework.ui.binding.Binding;
|
||||||
|
import org.springframework.ui.binding.BindingConfiguration;
|
||||||
import org.springframework.ui.binding.BindingResult;
|
import org.springframework.ui.binding.BindingResult;
|
||||||
import org.springframework.ui.binding.BindingResults;
|
import org.springframework.ui.binding.BindingResults;
|
||||||
import org.springframework.ui.binding.MissingSourceValuesException;
|
import org.springframework.ui.binding.MissingSourceValuesException;
|
||||||
|
|
@ -84,7 +85,7 @@ public class GenericBinder implements Binder {
|
||||||
|
|
||||||
private Object model;
|
private Object model;
|
||||||
|
|
||||||
private Set<BindingFactory> bindingFactories;
|
public Set<BindingFactory> bindingFactories;
|
||||||
|
|
||||||
private FormatterRegistry formatterRegistry = new GenericFormatterRegistry();
|
private FormatterRegistry formatterRegistry = new GenericFormatterRegistry();
|
||||||
|
|
||||||
|
|
@ -269,7 +270,7 @@ public class GenericBinder implements Binder {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
class BindingFactory {
|
public class BindingFactory {
|
||||||
|
|
||||||
private DefaultBindingConfiguration configuration;
|
private DefaultBindingConfiguration configuration;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue