|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
IForm.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;
|
|
16 |
|
|
17 |
import org.apache.tapestry.form.FormEventType;
|
|
18 |
import org.apache.tapestry.form.IFormComponent;
|
|
19 |
import org.apache.tapestry.valid.IValidationDelegate;
|
|
20 |
|
|
21 |
/**
|
|
22 |
* A generic way to access a component which defines an HTML form. This interface
|
|
23 |
* exists so that the {@link IRequestCycle} can invoke the
|
|
24 |
* {@link #rewind(IMarkupWriter, IRequestCycle)} method (which is used to deal with
|
|
25 |
* a Form that uses the direct service). In release 1.0.5, more responsibility
|
|
26 |
* for forms was moved here.
|
|
27 |
*
|
|
28 |
* @author Howard Lewis Ship
|
|
29 |
* @since 1.0.2
|
|
30 |
**/
|
|
31 |
|
|
32 |
public interface IForm extends IAction |
|
33 |
{ |
|
34 |
|
|
35 |
/**
|
|
36 |
* Attribute name used with the request cycle; allows other components to locate
|
|
37 |
* the IForm.
|
|
38 |
*
|
|
39 |
* @since 1.0.5
|
|
40 |
*
|
|
41 |
**/
|
|
42 |
|
|
43 |
public static final String ATTRIBUTE_NAME = "org.apache.tapestry.active.Form"; |
|
44 |
|
|
45 |
/**
|
|
46 |
* Invoked by the {@link IRequestCycle} to allow a form that uses
|
|
47 |
* the direct service, to respond to the form submission.
|
|
48 |
*
|
|
49 |
**/
|
|
50 |
|
|
51 |
public void rewind(IMarkupWriter writer, IRequestCycle cycle); |
|
52 |
|
|
53 |
/**
|
|
54 |
* Adds an additional event handler. The type determines when the
|
|
55 |
* handler will be invoked, {@link FormEventType#SUBMIT}
|
|
56 |
* is most typical.
|
|
57 |
*
|
|
58 |
* @since 1.0.5
|
|
59 |
*
|
|
60 |
**/
|
|
61 |
|
|
62 |
public void addEventHandler(FormEventType type, String functionName); |
|
63 |
|
|
64 |
/**
|
|
65 |
* Constructs a unique identifier (within the Form). The identifier
|
|
66 |
* consists of the component's id, with an index number added to
|
|
67 |
* ensure uniqueness.
|
|
68 |
*
|
|
69 |
* <p>Simply invokes {@link #getElementId(IFormComponent, String)} with the component's id.
|
|
70 |
*
|
|
71 |
*
|
|
72 |
* @since 1.0.5
|
|
73 |
*
|
|
74 |
**/
|
|
75 |
|
|
76 |
public String getElementId(IFormComponent component);
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Constructs a unique identifier from the base id. If possible, the
|
|
80 |
* id is used as-is. Otherwise, a unique identifier is appended
|
|
81 |
* to the id.
|
|
82 |
*
|
|
83 |
* <p>This method is provided simply so that some components
|
|
84 |
* ({@link org.apache.tapestry.form.ImageSubmit}) have more specific control over
|
|
85 |
* their names.
|
|
86 |
*
|
|
87 |
* <p>Invokes {@link IFormComponent#setName(String)} with the result, as well
|
|
88 |
* as returning it.
|
|
89 |
*
|
|
90 |
* @throws StaleLinkException if, when the form itself is rewinding, the
|
|
91 |
* element id allocated does not match the expected id (as allocated when the form rendered).
|
|
92 |
* This indicates that the state of the application has changed between the time the
|
|
93 |
* form renderred and the time it was submitted.
|
|
94 |
*
|
|
95 |
* @since 1.0.5
|
|
96 |
*
|
|
97 |
**/
|
|
98 |
|
|
99 |
public String getElementId(IFormComponent component, String baseId);
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Returns the name of the form.
|
|
103 |
*
|
|
104 |
* @since 1.0.5
|
|
105 |
*
|
|
106 |
**/
|
|
107 |
|
|
108 |
public String getName();
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Returns true if the form is rewinding (meaning, the form was the subject
|
|
112 |
* of the request cycle).
|
|
113 |
*
|
|
114 |
* @since 1.0.5
|
|
115 |
*
|
|
116 |
**/
|
|
117 |
|
|
118 |
public boolean isRewinding(); |
|
119 |
|
|
120 |
/**
|
|
121 |
* Returns the validation delegate for the form.
|
|
122 |
* Returns null if the form does not have a delegate.
|
|
123 |
*
|
|
124 |
* @since 1.0.8
|
|
125 |
*
|
|
126 |
**/
|
|
127 |
|
|
128 |
public IValidationDelegate getDelegate();
|
|
129 |
|
|
130 |
/**
|
|
131 |
* May be invoked by a component to force the encoding type of the
|
|
132 |
* form to a particular value.
|
|
133 |
*
|
|
134 |
* @see org.apache.tapestry.form.Upload
|
|
135 |
* @throws ApplicationRuntimeException if the current encoding type is not null
|
|
136 |
* and doesn't match the suggested encoding type
|
|
137 |
* @since 3.0
|
|
138 |
*
|
|
139 |
**/
|
|
140 |
|
|
141 |
public void setEncodingType(String encodingType); |
|
142 |
|
|
143 |
|
|
144 |
/**
|
|
145 |
* Adds a hidden field value to be stored in the form. This ensures that all
|
|
146 |
* of the <input type="hidden"> (or equivalent) are grouped together,
|
|
147 |
* which ensures that the output HTML is valid (ie. doesn't
|
|
148 |
* have <input> improperly nested with <tr>, etc.).
|
|
149 |
*
|
|
150 |
* <p>
|
|
151 |
* It is acceptible to add multiple hidden fields with the same name.
|
|
152 |
* They will be written in the order they are received.
|
|
153 |
*
|
|
154 |
* @since 3.0
|
|
155 |
*/
|
|
156 |
|
|
157 |
public void addHiddenValue(String name, String value); |
|
158 |
|
|
159 |
/**
|
|
160 |
* Adds a hidden field value to be stored in the form. This ensures that all
|
|
161 |
* of the <input type="hidden"> (or equivalent) are grouped together,
|
|
162 |
* which ensures that the output HTML is valid (ie. doesn't
|
|
163 |
* have <input> improperly nested with <tr>, etc.).
|
|
164 |
*
|
|
165 |
* <p>
|
|
166 |
* It is acceptible to add multiple hidden fields with the same name.
|
|
167 |
* They will be written in the order they are received.
|
|
168 |
*
|
|
169 |
* @since 3.0
|
|
170 |
*/
|
|
171 |
|
|
172 |
public void addHiddenValue(String name, String id, String value); |
|
173 |
} |
|