1 10 package org.mmbase.util; 11 12 import java.util.*; 13 import org.mmbase.util.logging.*; 14 15 38 public class HTMLElementRadio extends HTMLElement { 39 41 private static Logger log = Logging.getLoggerInstance(HTMLElementRadio.class.getName()); 43 44 47 public HTMLElementRadio() { 48 } 49 50 53 protected String generate() { 54 String val = null; 55 String html = ""; 56 57 if (selected != null && selected.equals("null")) { 58 sel = false; 59 } 60 if (exclude != null && exclude.equals("null")) { 61 ex = false; 62 } 63 64 if (moreValues) { 65 Enumeration e = valuesList.elements(); 66 String basic = "<input type=\"radio\" name=\"" + name + "\" value=\""; 67 68 Vector list = new Vector(); 69 70 String brk=""; 71 if (vertical) { 72 brk="<br />\n"; 73 } 74 while (e.hasMoreElements()) { 75 val = (String ) e.nextElement(); 76 if (sel && selected.equalsIgnoreCase(val)) { 77 list.addElement(basic +val + "\" checked >" + val + brk); 78 } else if (!ex || (!exclude.equalsIgnoreCase(val))) { 79 list.addElement(basic +val + "\" >" + val + brk); 80 } 81 122 } 123 Enumeration le = list.elements(); 124 int i=0; 125 String h = ""; 126 while(le.hasMoreElements()) { 127 while( i < 22 && le.hasMoreElements() ) { 128 h += (String ) le.nextElement(); 129 i++; 130 } 131 html += h; 132 h = ""; 133 i = 0; 134 } 135 } else if (moredouble) { 136 Enumeration e = valuesList.elements(); 137 String basic = "<input type=\"radio\" name=\"" + name + "\" value=\""; 138 139 Vector list = new Vector(); 140 141 String brk=""; 142 if (vertical) { 143 brk="<br />\n"; 144 } 145 while (e.hasMoreElements()) { 146 val = (String ) e.nextElement(); 147 String val2 ; 148 if (e.hasMoreElements()) { 149 val2= (String ) e.nextElement(); 150 } else { 151 log.error("HTMLElementRadio.generate: Expecting a double list (the DOUBLE key word was selected"); 152 return html; 153 } 154 if (sel && selected.equalsIgnoreCase(val)) { 155 list.addElement(basic +val2 + "\" checked >" + val + brk); 156 } else if (!ex || (!exclude.equalsIgnoreCase(val))) { 157 list.addElement(basic +val2 + "\" >" + val + brk); 158 } 159 199 } 200 201 Enumeration le = list.elements(); 202 int i=0; 203 String h = ""; 204 while(le.hasMoreElements()) 205 { 206 while( i < 22 && le.hasMoreElements() ) 207 { 208 h += (String ) le.nextElement(); 209 i++; 210 } 211 html += h; 212 h = ""; 213 i = 0; 214 } 215 } 216 else 217 { 218 html += "<input type=\"radio\" name=\""+name + "\" "; 219 if (sel) html += "checked "; 220 html += "value=\"" + values + "\">" + values ; 221 } 222 return html; 223 } 224 } 225 | Popular Tags |