diff --git a/org.springframework.context/src/main/java/org/springframework/ui/WebBindAndValidateLifecycle.java b/org.springframework.context/src/main/java/org/springframework/ui/WebBindAndValidateLifecycle.java index 69e1cd7aeee..6d8f2cf9bd8 100644 --- a/org.springframework.context/src/main/java/org/springframework/ui/WebBindAndValidateLifecycle.java +++ b/org.springframework.context/src/main/java/org/springframework/ui/WebBindAndValidateLifecycle.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2009 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,35 +24,47 @@ import org.springframework.ui.message.MessageContext; import org.springframework.ui.validation.ValidateResults; import org.springframework.ui.validation.Validator; +/** + * TODO Document WebBindAndValidateLifecycle. + * + * @author Keith Donald + * @since 3.0 + */ public class WebBindAndValidateLifecycle { - private WebBinder binder; - - @SuppressWarnings("unused") - private MessageContext messages; - + private final WebBinder binder; + + private final MessageContext messageContext; + private ValidationDecider validationDecider = ValidationDecider.ALWAYS_VALIDATE; - - private Validator validator; - - public WebBindAndValidateLifecycle(Object model, MessageContext messages) { + + private Validator validator = null; + + public WebBindAndValidateLifecycle(Object model, MessageContext messageContext) { this.binder = new WebBinder(model); + this.messageContext = messageContext; } - + + /** + * TODO Document execute(). + * + * @param userMap + */ public void execute(Map userMap) { UserValues values = binder.createUserValues(userMap); BindingResults bindingResults = binder.bind(values); if (validationDecider.shouldValidateAfter(bindingResults)) { - ValidateResults validationResults = validator.validate(binder.getModel(), bindingResults.successes().properties()); + ValidateResults validationResults = validator.validate(binder.getModel(), bindingResults.successes() + .properties()); } // TODO translate binding and validation results into messages } - - public interface ValidationDecider { - + + interface ValidationDecider { + boolean shouldValidateAfter(BindingResults results); - public static ValidationDecider ALWAYS_VALIDATE = new ValidationDecider() { + static final ValidationDecider ALWAYS_VALIDATE = new ValidationDecider() { public boolean shouldValidateAfter(BindingResults results) { return true; } diff --git a/org.springframework.context/src/main/java/org/springframework/ui/validation/ValidateResults.java b/org.springframework.context/src/main/java/org/springframework/ui/validation/ValidateResults.java new file mode 100644 index 00000000000..9dd8e7ea7fd --- /dev/null +++ b/org.springframework.context/src/main/java/org/springframework/ui/validation/ValidateResults.java @@ -0,0 +1,27 @@ +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ui.validation; + +/** + * TODO Document ValidateResults. + * + * @author Keith Donald + * @since 3.0 + */ +public interface ValidateResults { + +} diff --git a/org.springframework.context/src/main/java/org/springframework/ui/validation/Validator.java b/org.springframework.context/src/main/java/org/springframework/ui/validation/Validator.java new file mode 100644 index 00000000000..97ddf7785fd --- /dev/null +++ b/org.springframework.context/src/main/java/org/springframework/ui/validation/Validator.java @@ -0,0 +1,38 @@ +/* + * Copyright 2002-2009 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ui.validation; + +import java.util.List; + +/** + * TODO Document Validator. + * + * @author Keith Donald + * @since 3.0 + */ +public interface Validator { + + /** + * TODO Document validate(). + * + * @param model + * @param properties + * @return + */ + ValidateResults validate(Object model, List properties); + +} diff --git a/org.springframework.context/src/test/java/org/springframework/ui/validation/ValidateResults.java b/org.springframework.context/src/test/java/org/springframework/ui/validation/ValidateResults.java deleted file mode 100644 index ad01b8fc004..00000000000 --- a/org.springframework.context/src/test/java/org/springframework/ui/validation/ValidateResults.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.springframework.ui.validation; - -public interface ValidateResults { - -} diff --git a/org.springframework.context/src/test/java/org/springframework/ui/validation/Validator.java b/org.springframework.context/src/test/java/org/springframework/ui/validation/Validator.java deleted file mode 100644 index 14605d6a881..00000000000 --- a/org.springframework.context/src/test/java/org/springframework/ui/validation/Validator.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.springframework.ui.validation; - -import java.util.List; - -public interface Validator { - - ValidateResults validate(Object model, List properties); - -}