polish
This commit is contained in:
parent
6e05d3bd6e
commit
ab7e985d72
|
|
@ -62,23 +62,6 @@ public interface Binding {
|
||||||
*/
|
*/
|
||||||
boolean isVisible();
|
boolean isVisible();
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply the source value to this binding.
|
|
||||||
* The source value is parsed and stored in the binding's value buffer.
|
|
||||||
* Sets to {@link BindingStatus#DIRTY} if succeeds.
|
|
||||||
* Sets to {@link BindingStatus#INVALID_SOURCE_VALUE} if fails.
|
|
||||||
* @param sourceValue
|
|
||||||
* @throws IllegalStateException if not editable or not enabled
|
|
||||||
*/
|
|
||||||
void applySourceValue(Object sourceValue);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If {@link BindingStatus#INVALID_SOURCE_VALUE}, returns the invalid source value.
|
|
||||||
* Returns null otherwise.
|
|
||||||
* @return the invalid source value
|
|
||||||
*/
|
|
||||||
Object getInvalidSourceValue();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current binding status.
|
* The current binding status.
|
||||||
* Initially {@link BindingStatus#CLEAN clean}.
|
* Initially {@link BindingStatus#CLEAN clean}.
|
||||||
|
|
@ -99,6 +82,23 @@ public interface Binding {
|
||||||
*/
|
*/
|
||||||
Alert getStatusAlert();
|
Alert getStatusAlert();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply the source value to this binding.
|
||||||
|
* The source value is parsed and stored in the binding's value buffer.
|
||||||
|
* Sets to {@link BindingStatus#DIRTY} if succeeds.
|
||||||
|
* Sets to {@link BindingStatus#INVALID_SOURCE_VALUE} if fails.
|
||||||
|
* @param sourceValue
|
||||||
|
* @throws IllegalStateException if not editable or not enabled
|
||||||
|
*/
|
||||||
|
void applySourceValue(Object sourceValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If {@link BindingStatus#INVALID_SOURCE_VALUE}, returns the invalid source value.
|
||||||
|
* Returns null otherwise.
|
||||||
|
* @return the invalid source value
|
||||||
|
*/
|
||||||
|
Object getInvalidSourceValue();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commit the buffered value to the model.
|
* Commit the buffered value to the model.
|
||||||
* Sets to {@link BindingStatus#COMMITTED} if succeeds.
|
* Sets to {@link BindingStatus#COMMITTED} if succeeds.
|
||||||
|
|
@ -119,7 +119,7 @@ public interface Binding {
|
||||||
* @return the binding to the nested property
|
* @return the binding to the nested property
|
||||||
* @throws IllegalStateException if not a bean
|
* @throws IllegalStateException if not a bean
|
||||||
*/
|
*/
|
||||||
Binding getBinding(String property);
|
Binding getNestedBinding(String property);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If bound to an indexable Collection, either a {@link java.util.List} or an array.
|
* If bound to an indexable Collection, either a {@link java.util.List} or an array.
|
||||||
|
|
@ -155,58 +155,4 @@ public interface Binding {
|
||||||
* @return the formatted string
|
* @return the formatted string
|
||||||
*/
|
*/
|
||||||
String formatValue(Object potentialModelValue);
|
String formatValue(Object potentialModelValue);
|
||||||
|
|
||||||
/**
|
|
||||||
* Binding states.
|
|
||||||
* @author Keith Donald
|
|
||||||
*/
|
|
||||||
public enum BindingStatus {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initial state: No value is buffered, and there is a direct channel to the model value.
|
|
||||||
*/
|
|
||||||
CLEAN,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An invalid source value is applied.
|
|
||||||
*/
|
|
||||||
INVALID_SOURCE_VALUE,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The binding buffer contains a valid value that has not been committed.
|
|
||||||
*/
|
|
||||||
DIRTY,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The buffered value has been committed.
|
|
||||||
*/
|
|
||||||
COMMITTED,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The buffered value failed to commit.
|
|
||||||
*/
|
|
||||||
COMMIT_FAILURE
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validation states.
|
|
||||||
* @author Keith Donald
|
|
||||||
*/
|
|
||||||
public enum ValidationStatus {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initial state: No validation has run.
|
|
||||||
*/
|
|
||||||
NOT_VALIDATED,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validation has succeeded.
|
|
||||||
*/
|
|
||||||
VALID,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Validation has failed.
|
|
||||||
*/
|
|
||||||
INVALID
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package org.springframework.ui.binding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binding states.
|
||||||
|
* @author Keith Donald
|
||||||
|
*/
|
||||||
|
public enum BindingStatus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initial state: No value is buffered, and there is a direct channel to the model value.
|
||||||
|
*/
|
||||||
|
CLEAN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An invalid source value is applied.
|
||||||
|
*/
|
||||||
|
INVALID_SOURCE_VALUE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The binding buffer contains a valid value that has not been committed.
|
||||||
|
*/
|
||||||
|
DIRTY,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The buffered value has been committed.
|
||||||
|
*/
|
||||||
|
COMMITTED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The buffered value failed to commit.
|
||||||
|
*/
|
||||||
|
COMMIT_FAILURE
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.springframework.ui.binding;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation states.
|
||||||
|
* @author Keith Donald
|
||||||
|
*/
|
||||||
|
public enum ValidationStatus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initial state: No validation has run.
|
||||||
|
*/
|
||||||
|
NOT_VALIDATED,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation has succeeded.
|
||||||
|
*/
|
||||||
|
VALID,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation has failed.
|
||||||
|
*/
|
||||||
|
INVALID
|
||||||
|
}
|
||||||
|
|
@ -29,7 +29,7 @@ public interface BindingResult {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model property this binding result is for.
|
* The model property this binding result is for.
|
||||||
* @see Binder#getBinding(String)
|
* @see Binder#getNestedBinding(String)
|
||||||
*/
|
*/
|
||||||
String getProperty();
|
String getProperty();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import org.springframework.context.MessageSource;
|
||||||
import org.springframework.core.convert.TypeConverter;
|
import org.springframework.core.convert.TypeConverter;
|
||||||
import org.springframework.ui.binding.Binding;
|
import org.springframework.ui.binding.Binding;
|
||||||
import org.springframework.ui.binding.BindingFactory;
|
import org.springframework.ui.binding.BindingFactory;
|
||||||
import org.springframework.ui.binding.Binding.BindingStatus;
|
import org.springframework.ui.binding.BindingStatus;
|
||||||
import org.springframework.ui.binding.support.PropertyNotFoundException;
|
import org.springframework.ui.binding.support.PropertyNotFoundException;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import org.springframework.core.style.StylerUtils;
|
||||||
import org.springframework.ui.alert.Alert;
|
import org.springframework.ui.alert.Alert;
|
||||||
import org.springframework.ui.alert.Severity;
|
import org.springframework.ui.alert.Severity;
|
||||||
import org.springframework.ui.binding.Binding;
|
import org.springframework.ui.binding.Binding;
|
||||||
|
import org.springframework.ui.binding.BindingStatus;
|
||||||
import org.springframework.ui.format.Formatter;
|
import org.springframework.ui.format.Formatter;
|
||||||
import org.springframework.ui.message.MessageBuilder;
|
import org.springframework.ui.message.MessageBuilder;
|
||||||
import org.springframework.ui.message.ResolvableArgument;
|
import org.springframework.ui.message.ResolvableArgument;
|
||||||
|
|
@ -278,7 +279,7 @@ public class GenericBinding implements Binding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Binding getBinding(String property) {
|
public Binding getNestedBinding(String property) {
|
||||||
return bindingContext.getBinding(property);
|
return bindingContext.getBinding(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ public class GenericBindingFactory implements BindingFactory {
|
||||||
throw new IllegalArgumentException("Attempted to index a property that is not a List or Map");
|
throw new IllegalArgumentException("Attempted to index a property that is not a List or Map");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding = binding.getBinding(element.getValue());
|
binding = binding.getNestedBinding(element.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return binding;
|
return binding;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import org.junit.Test;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.core.style.ToStringCreator;
|
import org.springframework.core.style.ToStringCreator;
|
||||||
import org.springframework.ui.binding.Binding;
|
import org.springframework.ui.binding.Binding;
|
||||||
import org.springframework.ui.binding.Binding.BindingStatus;
|
import org.springframework.ui.binding.BindingStatus;
|
||||||
import org.springframework.ui.binding.binder.BindingResults;
|
import org.springframework.ui.binding.binder.BindingResults;
|
||||||
import org.springframework.ui.binding.binder.GenericBinder;
|
import org.springframework.ui.binding.binder.GenericBinder;
|
||||||
import org.springframework.ui.binding.binder.MissingSourceValuesException;
|
import org.springframework.ui.binding.binder.MissingSourceValuesException;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue