001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003: * Distributed under the terms of either:
004: * - the common development and distribution license (CDDL), v1.0; or
005: * - the GNU Lesser General Public License, v2.1 or later
006: * $Id: ValidatedConstrained.java 3634 2007-01-08 21:42:24Z gbevin $
007: */
008: package com.uwyn.rife.site;
009:
010: import java.util.Collection;
011: import java.util.List;
012:
013: /**
014: * This interface extends the Validated interface and provides additional
015: * methods that are related to beans that are constrained with {@link
016: * ConstrainedProperty} constraints.
017: * <p>One notable addition is the capability to handle {@link ValidationGroup}s.
018: *
019: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
020: * @version $Revision: 3634 $
021: * @see Validated
022: * @see Constrained
023: * @see ConstrainedProperty
024: * @see ValidationGroup
025: * @since 1.4
026: */
027: public interface ValidatedConstrained<P extends ConstrainedProperty>
028: extends Validated {
029: /**
030: * Adds a new validation group.
031: *
032: * @param name the name of the validation group that needs to be created
033: * and added
034: * @return the newly created <code>ValidationGroup</code>
035: * @since 1.4
036: */
037: public ValidationGroup<P> addGroup(String name);
038:
039: /**
040: * Focuses on one particular validation group, showing only the
041: * <code>ValidationError</code>s that were generated by its
042: * <code>ValidationRule</code>s.
043: *
044: * @param name the name of the validation group that will be focused
045: * @since 1.4
046: */
047: public void focusGroup(String name);
048:
049: /**
050: * Removed all the <code>ValidationError</code>s of a particular
051: * validation group.
052: *
053: * @param name the name of the validation group that will be focused
054: * @since 1.4
055: */
056: public void resetGroup(String name);
057:
058: /**
059: * Retrieves all validation groups.
060: *
061: * @return the collection of all registered validation groups
062: * @since 1.4
063: */
064: public Collection<ValidationGroup<P>> getGroups();
065:
066: /**
067: * Retrieve a particular validation group.
068: *
069: * @param name the name of the validation group that will be retrieved
070: * @return the requested <code>ValidationGroup</code>; or
071: * <p><code>null</code> if no such validation group exists
072: * @since 1.4
073: */
074: public ValidationGroup<P> getGroup(String name);
075:
076: /**
077: * Validate the <code>ValidationRule</code>s of a particular validation
078: * group.
079: *
080: * @param name the name of the validation group that will be retrieved
081: * @return <code>true</code> if no validation errors were generated; or
082: * <p><code>false</code> otherwise
083: * @since 1.4
084: */
085: public boolean validateGroup(String name);
086:
087: /**
088: * Validate the <code>ValidationRule</code>s of a particular validation
089: * group and also validates the entire bean within the provided
090: * <code>ValidationContext</code>
091: *
092: * @param name the name of the validation group
093: * @param context the <code>ValidationContext</code> in which this bean
094: * instance will be additionally validated
095: * @return <code>true</code> if no validation errors were generated; or
096: * <p><code>false</code> otherwise
097: * @since 1.6
098: */
099: public boolean validateGroup(String name, ValidationContext context);
100:
101: /**
102: * Adds the validation rules that are related to a particular {@link
103: * ConstrainedProperty}.
104: * <p>If the rules of this property name have already been added before
105: * through another <code>ConstrainedProperty</code> instance, its existing
106: * <code>ValidationRule</code>s will be erased and the previous
107: * constraints will be merged into the new
108: * <code>ConstrainedProperty</code> before adding its validation rules.
109: *
110: * @param constrainedProperty the ConstrainedProperty that will be
111: * inspected
112: * @return the list of generated {@link ValidationRule}s
113: * @since 1.4
114: */
115: public List<PropertyValidationRule> addConstrainedPropertyRules(
116: P constrainedProperty);
117:
118: /**
119: * Generates the validation rules that are related to a particular {@link
120: * ConstrainedProperty}.
121: *
122: * @param constrainedProperty the ConstrainedProperty that will be
123: * inspected
124: * @return the list of generated {@link ValidationRule}s
125: * @since 1.4
126: */
127: public List<PropertyValidationRule> generateConstrainedPropertyRules(
128: P constrainedProperty);
129:
130: /**
131: * Returns the collection of error messages that occurred during the
132: * loading of the content of a certain property.
133: *
134: * @param propertyName the name of the property whose loading errors
135: * should be obtained
136: * @return null if no errors occurred during the loading of the content of
137: * the provided property or if the property doesn't exist; or
138: * <p>the requested collection of error messages
139: * @since 1.4
140: */
141: public Collection<String> getLoadingErrors(String propertyName);
142: }
|