01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: **/package org.araneaframework.uilib.support;
16:
17: import org.araneaframework.uilib.form.control.MultiSelectControl;
18: import org.araneaframework.uilib.form.control.SelectControl;
19:
20: /**
21: * Represents one item in the combo-box of the select element.
22: * <p>
23: * {@link SelectControl} and {@link MultiSelectControl} manage a list of them.
24: * Each item is characterized by its value and label.
25: *
26: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
27: */
28: public class DisplayItem implements java.io.Serializable {
29: /**
30: * Item's label.
31: */
32: protected String displayString;
33: /**
34: * Item's value.
35: */
36: protected String value;
37:
38: protected boolean disabled;
39:
40: /**
41: * Creates a new instance of {@link DisplayItem}.
42: *
43: * @param displayString the label (or other string to show) of the item.
44: * @param value the value of the item.
45: */
46: public DisplayItem(String value, String displayString) {
47: this (value, displayString, false);
48: }
49:
50: /**
51: * Creates a new instance of {@link DisplayItem}.
52: *
53: * @param displayString the label (or other string to show) of the item.
54: * @param value the value of the item.
55: * @param disabled whether item is disabled
56: */
57: public DisplayItem(String value, String displayString,
58: boolean disabled) {
59: if ("".equals(value))
60: throw new RuntimeException(
61: "Empty strings are not allowed as values");
62:
63: this .displayString = displayString;
64: this .value = value;
65: this .disabled = disabled;
66: }
67:
68: /**
69: * Getter for property <code>label</code>.
70: *
71: * @return value of property <code>label</code>.
72: */
73: public java.lang.String getDisplayString() {
74: return displayString;
75: }
76:
77: /**
78: * Getter for property <code>value</code>.
79: *
80: * @return value of property <code>value</code>.
81: */
82: public java.lang.String getValue() {
83: return value;
84: }
85:
86: public boolean isDisabled() {
87: return disabled;
88: }
89:
90: public void setDisabled(boolean disabled) {
91: this.disabled = disabled;
92: }
93: }
|