|
|||||||||||||||||||
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 | |||||||||||||||
FormBehavior.java | - | - | - | - |
|
1 |
// Copyright 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.hivemind.ApplicationRuntimeException;
|
|
18 |
import org.apache.hivemind.Location;
|
|
19 |
import org.apache.tapestry.form.FormEventType;
|
|
20 |
import org.apache.tapestry.form.IFormComponent;
|
|
21 |
|
|
22 |
/**
|
|
23 |
* Common interface extended by {@link org.apache.tapestry.IForm} and
|
|
24 |
* {@link org.apache.tapestry.FormSupport}.
|
|
25 |
*
|
|
26 |
* @author Howard M. Lewis Ship
|
|
27 |
* @since 4.0
|
|
28 |
*/
|
|
29 |
public interface FormBehavior |
|
30 |
{ |
|
31 |
/**
|
|
32 |
* Adds an additional event handler. The type determines when the handler will be invoked,
|
|
33 |
* {@link FormEventType#SUBMIT}is most typical.
|
|
34 |
*/
|
|
35 |
public void addEventHandler(FormEventType type, String functionName); |
|
36 |
|
|
37 |
/**
|
|
38 |
* Adds a hidden field value to be stored in the form. This ensures that all of the <input
|
|
39 |
* type="hidden"> (or equivalent) are grouped together, which ensures that the output HTML is
|
|
40 |
* valid (ie. doesn't have <input> improperly nested with <tr>, etc.).
|
|
41 |
* <p>
|
|
42 |
* It is acceptible to add multiple hidden fields with the same name. They will be written in
|
|
43 |
* the order they are received.
|
|
44 |
*/
|
|
45 |
|
|
46 |
public void addHiddenValue(String name, String value); |
|
47 |
|
|
48 |
/**
|
|
49 |
* Adds a hidden field value to be stored in the form. This ensures that all of the <input
|
|
50 |
* type="hidden"> (or equivalent) are grouped together, which ensures that the output HTML is
|
|
51 |
* valid (ie. doesn't have <input> improperly nested with <tr>, etc.).
|
|
52 |
* <p>
|
|
53 |
* It is acceptible to add multiple hidden fields with the same name. They will be written in
|
|
54 |
* the order they are received.
|
|
55 |
*
|
|
56 |
* @since 3.0
|
|
57 |
*/
|
|
58 |
|
|
59 |
public void addHiddenValue(String name, String id, String value); |
|
60 |
|
|
61 |
/**
|
|
62 |
* Constructs a unique identifier (within the Form). The identifier consists of the component's
|
|
63 |
* id, with an index number added to ensure uniqueness.
|
|
64 |
* <p>
|
|
65 |
* Simply invokes {@link #getElementId(IFormComponent, String)}with the component's id.
|
|
66 |
*/
|
|
67 |
|
|
68 |
public String getElementId(IFormComponent component);
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Constructs a unique identifier from the base id. If possible, the id is used as-is.
|
|
72 |
* Otherwise, a unique identifier is appended to the id.
|
|
73 |
* <p>
|
|
74 |
* This method is provided simply so that some components (
|
|
75 |
* {@link org.apache.tapestry.form.ImageSubmit}) have more specific control over their names.
|
|
76 |
* <p>
|
|
77 |
* Invokes {@link IFormComponent#setName(String)}with the result, as well as returning it.
|
|
78 |
*
|
|
79 |
* @throws StaleLinkException
|
|
80 |
* if, when the form itself is rewinding, the element id allocated does not match
|
|
81 |
* the expected id (as allocated when the form rendered). This indicates that the
|
|
82 |
* state of the application has changed between the time the form renderred and the
|
|
83 |
* time it was submitted.
|
|
84 |
*/
|
|
85 |
|
|
86 |
public String getElementId(IFormComponent component, String baseId);
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Returns true if the form is rewinding (meaning, the form was the subject of the request
|
|
90 |
* cycle).
|
|
91 |
*/
|
|
92 |
|
|
93 |
public boolean isRewinding(); |
|
94 |
|
|
95 |
/**
|
|
96 |
* May be invoked by a component to force the encoding type of the form to a particular value.
|
|
97 |
*
|
|
98 |
* @see org.apache.tapestry.form.Upload
|
|
99 |
* @throws ApplicationRuntimeException
|
|
100 |
* if the current encoding type is not null and doesn't match the provided encoding
|
|
101 |
* type
|
|
102 |
*/
|
|
103 |
|
|
104 |
public void setEncodingType(String encodingType); |
|
105 |
|
|
106 |
/**
|
|
107 |
* Pre-renders the specified field, buffering the result for later use by
|
|
108 |
* {@link #wasPrerendered(IMarkupWriter, IComponent)}. Typically, it is a
|
|
109 |
* {@link org.apache.tapestry.valid.FieldLabel} component that pre-renders an associated
|
|
110 |
* field. This little dance is necessary to properly support field labels inside loops, and to
|
|
111 |
* handle the portlet action/render request cycle.
|
|
112 |
*
|
|
113 |
* @param writer
|
|
114 |
* the markup writer (from which a nested markup writer is obtained)
|
|
115 |
* @param field
|
|
116 |
* the field to pre-render. The field is responsible for invoking
|
|
117 |
* {@link #wasPrerendered(IMarkupWriter, IComponent)}.
|
|
118 |
* @param location
|
|
119 |
* an optional location (of the FieldLabel component) used when reporting errors.
|
|
120 |
*/
|
|
121 |
public void prerenderField(IMarkupWriter writer, IComponent field, Location location); |
|
122 |
|
|
123 |
/**
|
|
124 |
* Invoked by a form control component (a field) that may have been pre-rendered. If the field
|
|
125 |
* was pre-rendered, then the buffered output is printed into the writer and true is returned.
|
|
126 |
* Otherwise, false is returned.
|
|
127 |
*
|
|
128 |
* @return true if the field was pre-rendered and should do nothing during its render phase,
|
|
129 |
* false if the field should continue as normal.
|
|
130 |
*/
|
|
131 |
public boolean wasPrerendered(IMarkupWriter writer, IComponent field); |
|
132 |
|
|
133 |
/**
|
|
134 |
* Adds a deferred runnable, an object to be executed either before the </form> tag is
|
|
135 |
* rendered (when rendering), or before the form's listener is invoked (when rewinding).
|
|
136 |
* Runnables are executed in the order in which they are added.
|
|
137 |
*
|
|
138 |
* @param runnable
|
|
139 |
* the object to execute (which may not be null)
|
|
140 |
*/
|
|
141 |
|
|
142 |
public void addDeferredRunnable(Runnable runnable); |
|
143 |
|
|
144 |
} |
|