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.validation;
017
018 import org.springframework.binding.value.PropertyChangePublisher;
019
020 /**
021 * Adds the propertyChange and parent-child aspect to the
022 * {@link ValidationResults} interface. Listeners can be registered on
023 * validation changes of a specific property or on all changes. Additionally a
024 * validationResultsModel has to be aware of its parent-child relationships to
025 * forward these changes in its ValidationResults.
026 *
027 * @author Oliver Hutchison
028 */
029 public interface ValidationResultsModel extends ValidationResults, PropertyChangePublisher {
030
031 /** The name of the bound property <em>hasErrors</em>. */
032 String HAS_ERRORS_PROPERTY = "hasErrors";
033
034 /** The name of the bound property <em>hasWarnings</em>. */
035 String HAS_WARNINGS_PROPERTY = "hasWarnings";
036
037 /** The name of the bound property <em>hasInfos</em>. */
038 String HAS_INFO_PROPERTY = "hasInfo";
039
040 /**
041 * Adds a listener that will be notified when there is any change to the set
042 * of validation messages.
043 */
044 void addValidationListener(ValidationListener listener);
045
046 /**
047 * Removes the provided validation listener.
048 */
049 void removeValidationListener(ValidationListener listener);
050
051 /**
052 * Adds a listener that will be notified when there is any change to the set
053 * validation messages for the specified property.
054 */
055 void addValidationListener(String propertyName, ValidationListener listener);
056
057 /**
058 * Removes the provided validation listener.
059 */
060 void removeValidationListener(String propertyName, ValidationListener listener);
061
062 /**
063 * Add a validationResultsModel as a child to this one. Results originating
064 * from child models have to be taken into account by the parent.
065 *
066 * @param validationResultsModel
067 */
068 void add(ValidationResultsModel validationResultsModel);
069
070 /**
071 * Remove the given validationResultsModel from the list of children.
072 *
073 * @param validationResultsModel
074 */
075 void remove(ValidationResultsModel validationResultsModel);
076 }