polish
This commit is contained in:
parent
6e05d3bd6e
commit
ab7e985d72
|
|
@ -61,6 +61,26 @@ public interface Binding {
|
|||
* Used to determine if the user can see the field.
|
||||
*/
|
||||
boolean isVisible();
|
||||
|
||||
/**
|
||||
* The current binding status.
|
||||
* Initially {@link BindingStatus#CLEAN clean}.
|
||||
* Is {@link BindingStatus#DIRTY} after applying a source value to the value buffer.
|
||||
* Is {@link BindingStatus#COMMITTED} after successfully committing the buffered value.
|
||||
* Is {@link BindingStatus#INVALID_SOURCE_VALUE} if a source value could not be applied.
|
||||
* Is {@link BindingStatus#COMMIT_FAILURE} if a buffered value could not be committed.
|
||||
*/
|
||||
BindingStatus getStatus();
|
||||
|
||||
/**
|
||||
* An alert that communicates current status to the user.
|
||||
* Returns <code>null</code> if {@link BindingStatus#CLEAN} and {@link ValidationStatus#NOT_VALIDATED}.
|
||||
* Returns a {@link Severity#INFO} Alert with code <code>bindSuccess</code> when {@link BindingStatus#COMMITTED}.
|
||||
* Returns a {@link Severity#ERROR} Alert with code <code>typeMismatch</code> when {@link BindingStatus#INVALID_SOURCE_VALUE} or {@link BindingStatus#COMMIT_FAILURE} due to a value parse / type conversion error.
|
||||
* Returns a {@link Severity#FATAL} Alert with code <code>internalError</code> when {@link BindingStatus#COMMIT_FAILURE} due to a unexpected runtime exception.
|
||||
* Returns a {@link Severity#INFO} Alert describing results of validation if {@link ValidationStatus#VALID} or {@link ValidationStatus#INVALID}.
|
||||
*/
|
||||
Alert getStatusAlert();
|
||||
|
||||
/**
|
||||
* Apply the source value to this binding.
|
||||
|
|
@ -79,26 +99,6 @@ public interface Binding {
|
|||
*/
|
||||
Object getInvalidSourceValue();
|
||||
|
||||
/**
|
||||
* The current binding status.
|
||||
* Initially {@link BindingStatus#CLEAN clean}.
|
||||
* Is {@link BindingStatus#DIRTY} after applying a source value to the value buffer.
|
||||
* Is {@link BindingStatus#COMMITTED} after successfully committing the buffered value.
|
||||
* Is {@link BindingStatus#INVALID_SOURCE_VALUE} if a source value could not be applied.
|
||||
* Is {@link BindingStatus#COMMIT_FAILURE} if a buffered value could not be committed.
|
||||
*/
|
||||
BindingStatus getStatus();
|
||||
|
||||
/**
|
||||
* An alert that communicates current status to the user.
|
||||
* Returns <code>null</code> if {@link BindingStatus#CLEAN} and {@link ValidationStatus#NOT_VALIDATED}.
|
||||
* Returns a {@link Severity#INFO} Alert with code <code>bindSuccess</code> when {@link BindingStatus#COMMITTED}.
|
||||
* Returns a {@link Severity#ERROR} Alert with code <code>typeMismatch</code> when {@link BindingStatus#INVALID_SOURCE_VALUE} or {@link BindingStatus#COMMIT_FAILURE} due to a value parse / type conversion error.
|
||||
* Returns a {@link Severity#FATAL} Alert with code <code>internalError</code> when {@link BindingStatus#COMMIT_FAILURE} due to a unexpected runtime exception.
|
||||
* Returns a {@link Severity#INFO} Alert describing results of validation if {@link ValidationStatus#VALID} or {@link ValidationStatus#INVALID}.
|
||||
*/
|
||||
Alert getStatusAlert();
|
||||
|
||||
/**
|
||||
* Commit the buffered value to the model.
|
||||
* Sets to {@link BindingStatus#COMMITTED} if succeeds.
|
||||
|
|
@ -119,7 +119,7 @@ public interface Binding {
|
|||
* @return the binding to the nested property
|
||||
* @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.
|
||||
|
|
@ -155,58 +155,4 @@ public interface Binding {
|
|||
* @return the formatted string
|
||||
*/
|
||||
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.
|
||||
* @see Binder#getBinding(String)
|
||||
* @see Binder#getNestedBinding(String)
|
||||
*/
|
||||
String getProperty();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.springframework.context.MessageSource;
|
|||
import org.springframework.core.convert.TypeConverter;
|
||||
import org.springframework.ui.binding.Binding;
|
||||
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.util.Assert;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.springframework.core.style.StylerUtils;
|
|||
import org.springframework.ui.alert.Alert;
|
||||
import org.springframework.ui.alert.Severity;
|
||||
import org.springframework.ui.binding.Binding;
|
||||
import org.springframework.ui.binding.BindingStatus;
|
||||
import org.springframework.ui.format.Formatter;
|
||||
import org.springframework.ui.message.MessageBuilder;
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class GenericBindingFactory implements BindingFactory {
|
|||
throw new IllegalArgumentException("Attempted to index a property that is not a List or Map");
|
||||
}
|
||||
} else {
|
||||
binding = binding.getBinding(element.getValue());
|
||||
binding = binding.getNestedBinding(element.getValue());
|
||||
}
|
||||
}
|
||||
return binding;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import org.junit.Test;
|
|||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
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.GenericBinder;
|
||||
import org.springframework.ui.binding.binder.MissingSourceValuesException;
|
||||
|
|
|
|||
Loading…
Reference in New Issue