KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > util > tags > GroupOption


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.util.tags;
19
20 /**
21  * GroupOption is a simple JavaBean that can be used to fully specify
22  * the name, value, alt text and accesskey of either a <code>CheckBoxGroup</code>
23  * or a <code>RadioButtonGroup</code>. The name will appear in the HTML after
24  * the checkbox or radio button. The name attribute is required for outpu
25  * by the tags. The value can either be set separately or will default to
26  * the name. Optionally and alt text attribute and accesskey value can be
27  * provided.
28  */

29 public class GroupOption
30     implements java.io.Serializable JavaDoc
31 {
32     private String JavaDoc _name;
33     private String JavaDoc _value;
34     private String JavaDoc _alt;
35     private char _accessKey;
36
37
38     /**
39      * Default Constructor.
40      */

41     public GroupOption() {}
42
43     /**
44      * Construct a GroupOption setting the name.
45      */

46     public GroupOption(String JavaDoc name)
47     {
48         _name = name;
49     }
50
51     /**
52      * Construct a GroupOption setting the name and value.
53      */

54     public GroupOption(String JavaDoc name,String JavaDoc value)
55     {
56         _name = name;
57         _value = value;
58     }
59
60     /**
61      * Construct a GroupOption setting all the values.
62      */

63     public GroupOption(String JavaDoc name,String JavaDoc value,String JavaDoc alt, char accessKey)
64     {
65         _name = name;
66         _value = value;
67         _alt = alt;
68         _accessKey = accessKey;
69     }
70
71     /**
72      * Set the name of the option which will appear next to the option.
73      * @param name The name of the created option.
74      */

75     public void setName(String JavaDoc name) {
76         _name = name;
77     }
78
79     /**
80      * Get the name of the option.
81      * @return The name of the option that was set.
82      */

83     public String JavaDoc getName() {
84         return _name;
85     }
86
87     /**
88      * Set the value of the option. Thie value will be written out as
89      * the <code>value</code> attribute.
90      * @param value The name of the created option.
91      */

92     public void setValue(String JavaDoc value) {
93         _value = value;
94     }
95
96     /**
97      * Get the value of the option. If no value has been set
98      * this method will return value assigned to the <code>name</code>
99      * property.
100      * @return The value of the option.
101      */

102     public String JavaDoc getValue() {
103         return (_value != null) ? _value : _name;
104     }
105
106
107     /**
108      * Set the alt text of the option.
109      * @param alt The text that will be set for the <code>alt</code> attribute.
110      */

111     public void setAlt(String JavaDoc alt) {
112         _alt = alt;
113     }
114
115     /**
116      * Get the alt text of the option.
117      * @return The alt text of the option.
118      */

119     public String JavaDoc getAlt() {
120         return _alt;
121     }
122
123     /**
124      * Set the alt text of the option.
125      * @param accessKey The value that will be set for the
126      * <code>accesskey</code> attribute.
127      */

128     public void setAccessKey(char accessKey) {
129         _accessKey = accessKey;
130     }
131
132     /**
133      * Get the accesskey of the option.
134      * @return The accessKey of the option.
135      */

136     public char getAccessKey() {
137         return _accessKey;
138     }
139 }
140
Popular Tags