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 /**
019 * Sub-interface implemented by form models that can be part of a form model
020 * hierarchy.
021 * <p>
022 * In a HierarchicalFormModel:
023 * <ul>
024 * <li>the enabled state of the parent is inherited by the children. So if the
025 * parent is disabled then the child is also disabled; however if the child is
026 * disabled the parent might not be disabled.
027 * <li>the dirty state of the chidren is inherited by the parent. So if one or
028 * more of the children are dirty then the parent is also dirty. However if the
029 * parent is dirty the children my not be.
030 * <li>the readOnly state of the parent is inherited by the children. If the
031 * parent is readOnly, all children are readOnly as well. However a child may be
032 * readOnly while the parent is not.
033 * </ul>
034 *
035 * @author Oliver Hutchison
036 */
037 public interface HierarchicalFormModel extends FormModel {
038
039 /**
040 * Returns the parent form model or null of there is none.
041 */
042 HierarchicalFormModel getParent();
043
044 /**
045 * Returns an array of child form models.
046 */
047 FormModel[] getChildren();
048
049 /**
050 * Sets the parent form model.
051 */
052 void setParent(HierarchicalFormModel parent);
053
054 /**
055 * Remove the parent form model
056 */
057 void removeParent();
058
059 /**
060 * Adds a new child to the form model. The child form model will have it's
061 * parent set to this.
062 */
063 void addChild(HierarchicalFormModel child);
064
065 /**
066 * Removes a child from this form model.
067 */
068 void removeChild(HierarchicalFormModel child);
069 }