polish
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1361 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
c1e3c02307
commit
7aaf5065b9
|
|
@ -21,6 +21,7 @@ import org.springframework.ui.binding.BindingResults;
|
|||
import org.springframework.ui.binding.UserValues;
|
||||
import org.springframework.ui.binding.support.WebBinder;
|
||||
import org.springframework.ui.message.MessageContext;
|
||||
import org.springframework.ui.validation.ValidateResults;
|
||||
import org.springframework.ui.validation.Validator;
|
||||
|
||||
public class WebBindAndValidateLifecycle {
|
||||
|
|
@ -40,10 +41,11 @@ public class WebBindAndValidateLifecycle {
|
|||
|
||||
public void execute(Map<String, ? extends Object> userMap) {
|
||||
UserValues values = binder.createUserValues(userMap);
|
||||
BindingResults results = binder.bind(values);
|
||||
if (validationDecider.shouldValidateAfter(results)) {
|
||||
validator.validate(binder.getModel(), results.successes().properties());
|
||||
BindingResults bindingResults = binder.bind(values);
|
||||
if (validationDecider.shouldValidateAfter(bindingResults)) {
|
||||
ValidateResults validationResults = validator.validate(binder.getModel(), bindingResults.successes().properties());
|
||||
}
|
||||
// TODO translate binding and validation results into messages
|
||||
}
|
||||
|
||||
public interface ValidationDecider {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public interface BindingResults extends Iterable<BindingResult> {
|
|||
BindingResult get(int index);
|
||||
|
||||
/**
|
||||
* The list of properties for which binding was attempted.
|
||||
* The ordered list of properties for which a {@link BindingResult} was returned.
|
||||
*/
|
||||
List<String> properties();
|
||||
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ public class GenericBinder implements Binder {
|
|||
|
||||
}
|
||||
|
||||
|
||||
class BindingImpl implements Binding {
|
||||
|
||||
private Expression property;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.springframework.ui.format.number.IntegerFormatter;
|
|||
public class GenericBinderTests {
|
||||
|
||||
private TestBean bean;
|
||||
|
||||
private Binder binder;
|
||||
|
||||
@Before
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package org.springframework.ui.validation;
|
||||
|
||||
public interface ValidateResults {
|
||||
|
||||
}
|
||||
|
|
@ -4,6 +4,6 @@ import java.util.List;
|
|||
|
||||
public interface Validator {
|
||||
|
||||
void validate(Object model, List<String> properties);
|
||||
ValidateResults validate(Object model, List<String> properties);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue