Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
IFormComponent |
|
| 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.form; |
|
16 | ||
17 | import org.apache.tapestry.IComponent; |
|
18 | import org.apache.tapestry.IForm; |
|
19 | ||
20 | /** |
|
21 | * A common interface implemented by all form components (components that create interactive |
|
22 | * elements in the rendered page). |
|
23 | * |
|
24 | * @author Howard Lewis Ship |
|
25 | */ |
|
26 | ||
27 | public interface IFormComponent extends IComponent |
|
28 | { |
|
29 | /** |
|
30 | * Returns the {@link org.apache.tapestry.IForm} which contains the component, or null if the |
|
31 | * component is not contained by a form, or if the containing Form is not currently rendering. |
|
32 | */ |
|
33 | ||
34 | IForm getForm(); |
|
35 | ||
36 | /** |
|
37 | * Returns the name of the component, which is automatically generated during renderring. |
|
38 | * <p> |
|
39 | * This value is set inside the component's render method and is <em>not</em> cleared. If the |
|
40 | * component is inside a {@link org.apache.tapestry.components.ForBean}, the value returned is |
|
41 | * the most recent name generated for the component. |
|
42 | * <p> |
|
43 | * This property is made available to facilitate writing JavaScript that allows components (in |
|
44 | * the client web browser) to interact. |
|
45 | * <p> |
|
46 | * In practice, a {@link org.apache.tapestry.html.Script} component works with the |
|
47 | * {@link org.apache.tapestry.html.Body} component to get the JavaScript code inserted and |
|
48 | * referenced. |
|
49 | */ |
|
50 | ||
51 | String getName(); |
|
52 | ||
53 | /** |
|
54 | * Invoked by {@link IForm#getElementId(IFormComponent)} when a name is created for a form |
|
55 | * component. |
|
56 | * |
|
57 | * @since 3.0 |
|
58 | * @see org.apache.tapestry.FormBehavior#getElementId(IFormComponent) |
|
59 | */ |
|
60 | ||
61 | void setName(String name); |
|
62 | ||
63 | /** |
|
64 | * May be implemented to return a user-presentable, localized name for the component, which is |
|
65 | * used in labels or error messages. Most components simply return null. |
|
66 | * |
|
67 | * @since 1.0.9 |
|
68 | */ |
|
69 | ||
70 | String getDisplayName(); |
|
71 | ||
72 | /** |
|
73 | * Returns true if the component is disabled. This is important when the containing form is |
|
74 | * submitted, since disabled parameters do not update their bindings. |
|
75 | * |
|
76 | * @since 2.2 |
|
77 | */ |
|
78 | ||
79 | boolean isDisabled(); |
|
80 | ||
81 | /** |
|
82 | * Returns the component's client-side element id. Typically, this is specified using an id |
|
83 | * parameter on the component and is passed through |
|
84 | * {@link org.apache.tapestry.IRequestCycle#getUniqueId(String)} to ensure that it is unique. |
|
85 | * The component is expected to write an id attribute (if it has a non null id). As with |
|
86 | * {@link #getName()}, if a component renders more than once (such as inside a loop) then on |
|
87 | * each render it will have a different clientId. |
|
88 | * |
|
89 | * <p> |
|
90 | * <b>Note:</b>Though semantically this method should result in the roughly the same results, |
|
91 | * the method used to create unique client ID's on form components is <i>not</i> the same as that |
|
92 | * defined in {@link IComponent}. |
|
93 | * </p> |
|
94 | * |
|
95 | * @return the id, or null if the component doesn't support an id. |
|
96 | * @since 4.0 |
|
97 | */ |
|
98 | ||
99 | String getClientId(); |
|
100 | ||
101 | /** |
|
102 | * Returns true if the field is required. This will (typically) involve consulting the |
|
103 | * component's validators. |
|
104 | * |
|
105 | * @since 4.0 |
|
106 | */ |
|
107 | ||
108 | boolean isRequired(); |
|
109 | } |