KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > form > IFormComponent


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, of if the containing Form is not currently renderring.
32      */

33
34     public 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.Foreach}, 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     public String JavaDoc 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     public void setName(String JavaDoc 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     public String JavaDoc 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     public 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      * @return the id, or null if the component doesn't support an id.
90      * @since 4.0
91      */

92
93     public String JavaDoc getClientId();
94 }
Popular Tags