Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
IFieldTracking |
|
| 1.0;1 |
1 | // Copyright 2004, 2005 The Apache Software Foundation |
|
2 | // |
|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
|
4 | // you may not use this file except in compliance with the License. |
|
5 | // You may obtain a copy of the License at |
|
6 | // |
|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | // |
|
9 | // Unless required by applicable law or agreed to in writing, software |
|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12 | // See the License for the specific language governing permissions and |
|
13 | // limitations under the License. |
|
14 | ||
15 | package org.apache.tapestry.valid; |
|
16 | ||
17 | import org.apache.tapestry.IRender; |
|
18 | import org.apache.tapestry.form.IFormComponent; |
|
19 | ||
20 | /** |
|
21 | * Defines the interface for an object that tracks input fields. This interface |
|
22 | * is now poorly named, in that it tracks errors that may <em>not</em> be |
|
23 | * associated with a specific field. |
|
24 | * <p> |
|
25 | * For each field, a flag is stored indicating if the field is, in fact, in |
|
26 | * error. The input supplied by the client is stored so that if the form is |
|
27 | * re-rendered (as is typically done when there are input errors), the value |
|
28 | * entered by the user can be displayed back to the user. An error message |
|
29 | * renderer is stored; this is an object that can render the error message (it |
|
30 | * is usually a {@link org.apache.tapestry.valid.RenderString} wrapper |
|
31 | * around a simple string). |
|
32 | * |
|
33 | * @author Howard Lewis Ship |
|
34 | * @since 1.0.8 |
|
35 | */ |
|
36 | ||
37 | public interface IFieldTracking |
|
38 | { |
|
39 | ||
40 | /** |
|
41 | * Returns true if the field is in error (that is, if it has an error |
|
42 | * message {@link #getErrorRenderer() renderer}. |
|
43 | * |
|
44 | * @return Whether or not field is in error. |
|
45 | */ |
|
46 | ||
47 | boolean isInError(); |
|
48 | ||
49 | /** |
|
50 | * Whether or not any errors found should cause field decoration / error |
|
51 | * renderers to render. This is set to false on form submissions (such as a |
|
52 | * refresh submit) where validation shouldn't cause errors to be rendererd. |
|
53 | * |
|
54 | * @return Whether or not to render errors, default is true. |
|
55 | */ |
|
56 | boolean getRenderError(); |
|
57 | ||
58 | /** |
|
59 | * Sets whether or not to render errors for this tracking. Gets |
|
60 | * set to false on form refresh submits. |
|
61 | * |
|
62 | * @param value Whether or not to render errors. |
|
63 | */ |
|
64 | void setRenderError(boolean value); |
|
65 | ||
66 | /** |
|
67 | * Returns the field component. This may return null if the error is not |
|
68 | * associated with any particular field. Note: may return null after the |
|
69 | * field tracking object is serialized and deserialized (the underlying |
|
70 | * component reference is transient); this metehod is primarily used for |
|
71 | * testing. |
|
72 | * |
|
73 | * @return The associated component, or null if not specific to a component. |
|
74 | */ |
|
75 | ||
76 | IFormComponent getComponent(); |
|
77 | ||
78 | /** |
|
79 | * Returns an object that will render the error message. The renderer |
|
80 | * <em>must</em> implement a simple <code>toString()</code> that does |
|
81 | * not produce markup, but is a simple message. |
|
82 | * |
|
83 | * @return The {@link IRender} responsible for rendering the error, or null if none is set. |
|
84 | * @see ValidatorException#ValidatorException(String, IRender, |
|
85 | * ValidationConstraint) |
|
86 | * @since 1.0.9 |
|
87 | */ |
|
88 | ||
89 | IRender getErrorRenderer(); |
|
90 | ||
91 | /** |
|
92 | * Returns the invalid input recorded for the field. This is stored so that, |
|
93 | * on a subsequent render, the smae invalid input can be presented to the |
|
94 | * client to be corrected. |
|
95 | * |
|
96 | * @return The original input value. |
|
97 | */ |
|
98 | String getInput(); |
|
99 | ||
100 | /** |
|
101 | * Returns the name of the field, that is, the name assigned by the form |
|
102 | * (this will differ from the component's id when any kind of looping |
|
103 | * operation is in effect). |
|
104 | * |
|
105 | * @return The name of the field within the form. |
|
106 | */ |
|
107 | ||
108 | String getFieldName(); |
|
109 | ||
110 | /** |
|
111 | * Returns the validation constraint that was violated by the input. This |
|
112 | * may be null if the constraint isn't known. |
|
113 | * |
|
114 | * @return The associated {@link ValidationConstraint} that caused the field error. |
|
115 | */ |
|
116 | ||
117 | ValidationConstraint getConstraint(); |
|
118 | } |