|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
IFieldTracking.java | - | - | - | - |
|
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 is now poorly named, | |
22 | * in that it tracks errors that may <em>not</em> be associated with a specific field. | |
23 | * <p> | |
24 | * For each field, a flag is stored indicating if the field is, in fact, in error. The input | |
25 | * supplied by the client is stored so that if the form is re-rendered (as is typically done when | |
26 | * there are input errors), the value entered by the user can be displayed back to the user. An | |
27 | * error message renderer is stored; this is an object that can render the error message (it is | |
28 | * usually a {@link org.apache.tapestry.valid.RenderString} wrapper around a simple string). | |
29 | * | |
30 | * @author Howard Lewis Ship | |
31 | * @since 1.0.8 | |
32 | */ | |
33 | ||
34 | public interface IFieldTracking | |
35 | { | |
36 | /** | |
37 | * Returns true if the field is in error (that is, if it has an error message | |
38 | * {@link #getErrorRenderer() renderer}. | |
39 | */ | |
40 | ||
41 | public boolean isInError(); | |
42 | ||
43 | /** | |
44 | * Returns the field component. This may return null if the error is not associated with any | |
45 | * particular field. Note: may return null after the field tracking object is serialized and | |
46 | * deserialized (the underlying component reference is transient); this metehod is primarily | |
47 | * used for testing. | |
48 | */ | |
49 | ||
50 | public IFormComponent getComponent(); | |
51 | ||
52 | /** | |
53 | * Returns an object that will render the error message. The renderer <em>must</em> implement | |
54 | * a simple <code>toString()</code> that does not produce markup, but is a simple message. | |
55 | * | |
56 | * @see ValidatorException#ValidatorException(String, IRender, ValidationConstraint) | |
57 | * @since 1.0.9 | |
58 | */ | |
59 | ||
60 | public IRender getErrorRenderer(); | |
61 | ||
62 | /** | |
63 | * Returns the invalid input recorded for the field. This is stored so that, on a subsequent | |
64 | * render, the smae invalid input can be presented to the client to be corrected. | |
65 | */ | |
66 | ||
67 | public String getInput(); | |
68 | ||
69 | /** | |
70 | * Returns the name of the field, that is, the name assigned by the form (this will differ from | |
71 | * the component's id when any kind of looping operation is in effect). | |
72 | */ | |
73 | ||
74 | public String getFieldName(); | |
75 | ||
76 | /** | |
77 | * Returns the validation constraint that was violated by the input. This may be null if the | |
78 | * constraint isn't known. | |
79 | */ | |
80 | ||
81 | public ValidationConstraint getConstraint(); | |
82 | } |
|