KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > gui > control > SelectOption


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.gui.control;
14
15 import info.magnolia.cms.core.Content;
16
17
18 /**
19  * @author Vinzenz Wyser
20  * @version 2.0
21  */

22 public class SelectOption extends ControlImpl {
23
24     private String JavaDoc label;
25
26     private boolean selected;
27
28     public SelectOption() {
29     }
30
31     public SelectOption(String JavaDoc label, String JavaDoc value) {
32         this.setLabel(label);
33         this.setValue(value);
34     }
35
36     public SelectOption(String JavaDoc label, Content websiteNode) {
37         this.setLabel(label);
38         this.setWebsiteNode(websiteNode);
39     }
40
41     public void setSelected(boolean b) {
42         this.selected = b;
43     }
44
45     public boolean getSelected() {
46         return this.selected;
47     }
48
49     public void setLabel(String JavaDoc s) {
50         this.label = s;
51     }
52
53     public String JavaDoc getLabel() {
54         if (this.label != null) {
55             return this.label;
56         }
57
58         return this.getValue();
59     }
60
61     public String JavaDoc getHtml() {
62         StringBuffer JavaDoc html = new StringBuffer JavaDoc();
63         html.append("<option value=\"" + this.getValue() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
64
html.append(this.getHtmlCssClass());
65         html.append(this.getHtmlCssStyles());
66         if (this.getSelected()) {
67             html.append(" selected"); //$NON-NLS-1$
68
}
69         html.append(this.getHtmlId()); // id e.g. needed in rich editor
70
html.append(">"); //$NON-NLS-1$
71
// html.append("["+this.getLabel()+"]["+this.getValue()+"]");
72
html.append(this.getLabel());
73         html.append("</option>"); //$NON-NLS-1$
74
return html.toString();
75     }
76 }
77
Popular Tags