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 | ||
45 | boolean isInError(); |
|
46 | ||
47 | /** |
|
48 | * Returns the field component. This may return null if the error is not |
|
49 | * associated with any particular field. Note: may return null after the |
|
50 | * field tracking object is serialized and deserialized (the underlying |
|
51 | * component reference is transient); this metehod is primarily used for |
|
52 | * testing. |
|
53 | */ |
|
54 | ||
55 | IFormComponent getComponent(); |
|
56 | ||
57 | /** |
|
58 | * Returns an object that will render the error message. The renderer |
|
59 | * <em>must</em> implement a simple <code>toString()</code> that does |
|
60 | * not produce markup, but is a simple message. |
|
61 | * |
|
62 | * @see ValidatorException#ValidatorException(String, IRender, |
|
63 | * ValidationConstraint) |
|
64 | * @since 1.0.9 |
|
65 | */ |
|
66 | ||
67 | IRender getErrorRenderer(); |
|
68 | ||
69 | /** |
|
70 | * Returns the invalid input recorded for the field. This is stored so that, |
|
71 | * on a subsequent render, the smae invalid input can be presented to the |
|
72 | * client to be corrected. |
|
73 | */ |
|
74 | ||
75 | String getInput(); |
|
76 | ||
77 | /** |
|
78 | * Returns the name of the field, that is, the name assigned by the form |
|
79 | * (this will differ from the component's id when any kind of looping |
|
80 | * operation is in effect). |
|
81 | */ |
|
82 | ||
83 | String getFieldName(); |
|
84 | ||
85 | /** |
|
86 | * Returns the validation constraint that was violated by the input. This |
|
87 | * may be null if the constraint isn't known. |
|
88 | */ |
|
89 | ||
90 | ValidationConstraint getConstraint(); |
|
91 | } |