Browse Source

moved binding configuration to publis binder api

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1538 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Keith Donald 17 years ago
parent
commit
edcd166681
  1. 21
      org.springframework.context/src/main/java/org/springframework/ui/binding/Binder.java
  2. 5
      org.springframework.context/src/main/java/org/springframework/ui/binding/BindingConfiguration.java
  3. 1
      org.springframework.context/src/main/java/org/springframework/ui/binding/support/DefaultBindingConfiguration.java
  4. 5
      org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java

21
org.springframework.context/src/main/java/org/springframework/ui/binding/Binder.java

@ -21,6 +21,7 @@ import java.util.Map; @@ -21,6 +21,7 @@ import java.util.Map;
* Binds user-entered values to properties of a model object.
* @author Keith Donald
* @since 3.0
* @see #addBinding(String)
* @see #getBinding(String)
* @see #bind(Map)
*/
@ -31,6 +32,26 @@ public interface Binder { @@ -31,6 +32,26 @@ public interface Binder {
*/
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&lt;Address&gt; 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..
* @param property the property path

5
org.springframework.context/src/main/java/org/springframework/ui/binding/support/BindingConfiguration.java → org.springframework.context/src/main/java/org/springframework/ui/binding/BindingConfiguration.java

@ -13,12 +13,13 @@ @@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* 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;
/**
* 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
* @see GenericBinder#addBinding(String)
*/

1
org.springframework.context/src/main/java/org/springframework/ui/binding/support/DefaultBindingConfiguration.java

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
*/
package org.springframework.ui.binding.support;
import org.springframework.ui.binding.BindingConfiguration;
import org.springframework.ui.format.Formatter;
final class DefaultBindingConfiguration implements BindingConfiguration {

5
org.springframework.context/src/main/java/org/springframework/ui/binding/support/GenericBinder.java

@ -55,6 +55,7 @@ import org.springframework.ui.alert.Alert; @@ -55,6 +55,7 @@ import org.springframework.ui.alert.Alert;
import org.springframework.ui.alert.Severity;
import org.springframework.ui.binding.Binder;
import org.springframework.ui.binding.Binding;
import org.springframework.ui.binding.BindingConfiguration;
import org.springframework.ui.binding.BindingResult;
import org.springframework.ui.binding.BindingResults;
import org.springframework.ui.binding.MissingSourceValuesException;
@ -84,7 +85,7 @@ public class GenericBinder implements Binder { @@ -84,7 +85,7 @@ public class GenericBinder implements Binder {
private Object model;
private Set<BindingFactory> bindingFactories;
public Set<BindingFactory> bindingFactories;
private FormatterRegistry formatterRegistry = new GenericFormatterRegistry();
@ -269,7 +270,7 @@ public class GenericBinder implements Binder { @@ -269,7 +270,7 @@ public class GenericBinder implements Binder {
return context;
}
class BindingFactory {
public class BindingFactory {
private DefaultBindingConfiguration configuration;

Loading…
Cancel
Save