1 10 package org.mmbase.util; 11 12 import java.util.Enumeration ; 13 import java.util.Vector ; 14 15 import org.mmbase.module.ProcessorInterface; 16 import org.mmbase.util.logging.Logger; 17 import org.mmbase.util.logging.Logging; 18 19 76 public class HTMLFormGenerator { 77 private static Logger log = Logging.getLoggerInstance(HTMLFormGenerator.class.getName()); 79 80 83 protected HTMLElementTextArea textArea; 84 85 88 protected HTMLElementRadio radio; 89 92 protected HTMLElementSelect select; 93 96 protected HTMLElementCheckBox checkBox; 97 100 protected HTMLElementText text; 101 104 protected HTMLElementPassword password; 105 106 109 public HTMLFormGenerator() { 110 textArea = new HTMLElementTextArea(); 111 radio = new HTMLElementRadio(); 112 select = new HTMLElementSelect(); 113 checkBox = new HTMLElementCheckBox(); 114 text = new HTMLElementText(); 115 password = new HTMLElementPassword(); 116 } 117 118 126 public String getHTMLElement (scanpage sp,ProcessorInterface proc, Vector macro) { 127 String type = getFirstElement(macro); 128 Vector params = getTailElements(macro); 129 130 if (type.equalsIgnoreCase("TEXTAREA")) { 131 return textArea.generateHTML(sp,proc,params); 133 } 134 135 if (type.equalsIgnoreCase("RADIO")) { 136 String radioHTML = radio.generateHTML(sp,proc,params) ; 138 return radioHTML; 139 } 140 141 if (type.equalsIgnoreCase("SELECT")) { 142 String selectHTML = select.generateHTML(sp,proc,params) ; 144 return selectHTML; 145 } 146 147 if (type.equalsIgnoreCase("CHECKBOX")) { 148 String checkBoxHTML = checkBox.generateHTML(sp,proc,params) ; 150 return checkBoxHTML; 151 } 152 153 if (type.equalsIgnoreCase("TEXT")) { 154 String textHTML = text.generateHTML(sp,proc,params) ; 156 return textHTML; 157 } 158 159 if (type.equalsIgnoreCase("PASSWORD")) { 160 String passwordHTML = password.generateHTML(sp,proc,params) ; 162 return passwordHTML; 163 } 164 log.error("HTMLFormGenerator: Unknown HTML type re quested: " + type); 165 return null; 166 } 167 168 171 protected Vector getTailElements(Vector vector) { 172 Enumeration e = vector.elements(); 173 if (e.hasMoreElements()) { 174 e.nextElement(); 177 178 Vector tailToReturn = new Vector (); 179 181 while(e.hasMoreElements()) { 182 tailToReturn.addElement(e.nextElement()); 183 } 184 return tailToReturn; 185 } else { 186 log.error("Empty Vector in HTMLFormGenerator"); 187 return null; 188 } 189 190 } 191 194 protected String getFirstElement(Vector vector) { 195 return (String ) vector.elementAt(0); 196 } 197 } 198 | Popular Tags |