1 13 package info.magnolia.cms.gui.control; 14 15 import info.magnolia.cms.core.Content; 16 17 18 22 public class SelectOption extends ControlImpl { 23 24 private String label; 25 26 private boolean selected; 27 28 public SelectOption() { 29 } 30 31 public SelectOption(String label, String value) { 32 this.setLabel(label); 33 this.setValue(value); 34 } 35 36 public SelectOption(String 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 s) { 50 this.label = s; 51 } 52 53 public String getLabel() { 54 if (this.label != null) { 55 return this.label; 56 } 57 58 return this.getValue(); 59 } 60 61 public String getHtml() { 62 StringBuffer html = new StringBuffer (); 63 html.append("<option value=\"" + this.getValue() + "\""); html.append(this.getHtmlCssClass()); 65 html.append(this.getHtmlCssStyles()); 66 if (this.getSelected()) { 67 html.append(" selected"); } 69 html.append(this.getHtmlId()); html.append(">"); html.append(this.getLabel()); 73 html.append("</option>"); return html.toString(); 75 } 76 } 77 | Popular Tags |