KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > html > HtmlFocusBaseTag


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.tags.html;
19
20 import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
21
22 /**
23  * Abstract base class which implements support for the input tag. This class introduces the following
24  * event attributes which are found on the &lt;input> element: <code>onblur</code>, <code>onfocus</code>,
25  * <code>onchange</code>, <code>onselect</code>. In addition, the <code>disable</code> attribute
26  * is added.
27  */

28 abstract public class HtmlFocusBaseTag extends HtmlBaseTag
29 {
30     private boolean _disabled; // Is the html control disabled?
31

32     /**
33      * Set the disable state either with the literal "true" or "false"
34      * or with an expression.
35      * @param disabled true or false or an expression
36      * @jsptagref.attributedescription Set the disable state either with the literal "true"
37      * or "false" or with an expression.
38      * @jsptagref.databindable false
39      * @jsptagref.attributesyntaxvalue <i>boolean_disabled</i>
40      * @netui:attribute required="false" rtexprvalue="true" type="boolean"
41      * description="Set the disable state either with the literal "true" or "false"
42      * or with an expression."
43      */

44     public void setDisabled(boolean disabled)
45     {
46         _disabled = disabled;
47     }
48
49     /**
50      * This method will a boolean indicating if the control is disabled or not. This will cause the
51      * disable attribute to be evaluated which may result in a runtime error or a JspException.
52      * @return <code>true</code> if the control is disabled.
53      */

54     protected final boolean isDisabled()
55     {
56         return _disabled;
57     }
58
59     /**
60      * Sets the onBlur javascript event.
61      * @param onblur the onBlur event.
62      * @jsptagref.attributedescription The onBlur JavaScript event.
63      * @jsptagref.databindable false
64      * @jsptagref.attributesyntaxvalue <i>string_onBlur</i>
65      * @netui:attribute required="false" rtexprvalue="true"
66      * description="Sets the onBlur javascript event."
67      */

68     public void setOnBlur(String JavaDoc onblur)
69     {
70         AbstractHtmlState tsh = getState();
71         tsh.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONBLUR, onblur);
72     }
73
74     /**
75      * Sets the onFocus javascript event.
76      * @param onfocus the onFocus event.
77      * @jsptagref.attributedescription The onFocus JavaScript event.
78      * @jsptagref.databindable false
79      * @jsptagref.attributesyntaxvalue <i>string_onFocus</i>
80      * @netui:attribute required="false" rtexprvalue="true"
81      * description="Sets the onFocus javascript event."
82      */

83     public void setOnFocus(String JavaDoc onfocus)
84     {
85         AbstractHtmlState tsh = getState();
86         tsh.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONFOCUS, onfocus);
87     }
88
89     /**
90      * Sets the onChange javascript event.
91      * @param onchange the onChange event.
92      * @jsptagref.attributedescription The onChange JavaScript event.
93      * @jsptagref.databindable false
94      * @jsptagref.attributesyntaxvalue <i>string_onChange</i>
95      * @netui:attribute required="false" rtexprvalue="true"
96      * description="Sets the onChange javascript event."
97      */

98     public void setOnChange(String JavaDoc onchange)
99     {
100         AbstractHtmlState tsh = getState();
101         tsh.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCHANGE, onchange);
102     }
103
104     /**
105      * Sets the onSelect javascript event.
106      * @param onselect the onSelect event.
107      * @jsptagref.attributedescription The onSelect JavaScript event.
108      * @jsptagref.databindable false
109      * @jsptagref.attributesyntaxvalue <i>string_onSelect</i>
110      * @netui:attribute required="false" rtexprvalue="true"
111      * description="Sets the onSelect javascript event."
112      */

113     public void setOnSelect(String JavaDoc onselect)
114     {
115         AbstractHtmlState tsh = getState();
116         tsh.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONSELECT, onselect);
117     }
118
119     protected void localRelease()
120     {
121         super.localRelease();
122         _disabled = false;
123     }
124 }
125
Popular Tags