001 /*
002 * Copyright 2002-2004 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016 package org.springframework.binding.form;
017
018 import org.springframework.binding.validation.ValidationMessage;
019 import org.springframework.binding.validation.ValidationResultsModel;
020 import org.springframework.binding.validation.Validator;
021
022 /**
023 * Sub-interface implemented by form models that can validate its own
024 * properties.
025 *
026 * @author Keith Donald
027 * @author Oliver Hutchison
028 */
029 public interface ValidatingFormModel extends ConfigurableFormModel, HierarchicalFormModel {
030
031 public static final String VALIDATING_PROPERTY = "validating";
032
033 /**
034 * Returns the ValidationResultsModel which encapsulates the set of
035 * validation messages currently active against this form model. Will be
036 * empty if validation is disabled.
037 */
038 ValidationResultsModel getValidationResults();
039
040 /**
041 * Does this ValidatingFormModel or any of its children contain errors?
042 */
043 boolean getHasErrors();
044
045 /**
046 * Is this form model currently validating?
047 */
048 boolean isValidating();
049
050 /**
051 * Sets whether or not validation is currently enabled for this form model.
052 * If validation is enabled the form model will immediately validate all
053 * form properties. If validation is disabled all validation messages held
054 * by the ValidationResultsModel will be cleared.
055 */
056 void setValidating(boolean validating);
057
058 /**
059 * Forces the form model to validate its self. If validation is disabled it
060 * does nothing.
061 */
062 void validate();
063
064 /**
065 * Get the validator that will be used to validate the form model.
066 */
067 Validator getValidator();
068
069 /**
070 * Set the validator that will be used to validate the form model.
071 */
072 void setValidator(Validator validator);
073
074 /**
075 * Provide validation messages that are generated by a process separate from
076 * the standard Validator.
077 * <p>
078 * All error messages that are raised using this method must be cleared
079 * using the method {@link #cleanValdationMessage(ValidationMessage)} before
080 * the form model can be commited.
081 *
082 * @param validationMessage the message to raise
083 */
084 void raiseValidationMessage(ValidationMessage validationMessage);
085
086 /**
087 * Clear validation messages that are generated by a process separate from
088 * the standard Validator.
089 *
090 * @param validationMessage the message to clear
091 */
092 void clearValidationMessage(ValidationMessage validationMessage);
093
094 }