1 64 65 package com.jcorporate.expresso.services.html; 66 67 72 73 import java.io.PrintWriter ; 74 import java.util.Enumeration ; 75 76 77 83 public class Form 84 extends HtmlElement { 85 private String action = null; 86 private String encoding = null; 87 private String method = ("POST"); 88 private String thisClass = (this.getClass().getName() + "."); 89 90 95 public Form() 96 throws HtmlException { 97 super(); 98 } 99 100 107 public Form(HtmlElement newElement) 108 throws HtmlException { 109 super(newElement); 110 } 111 112 119 public Form(String newName) 120 throws HtmlException { 121 super(newName); 122 } 123 124 131 protected synchronized void display(PrintWriter out, int depth) 132 throws HtmlException { 133 String myName = (thisClass + "display(PrintWriter)"); 134 135 if (contents.size() == 0) { 136 throw new HtmlException(myName + ":Form " + getName() + 137 " has no contents"); 138 } 139 140 this.padWithTabs(out, depth); 141 out.print("<form"); 142 143 if (cSSClass != null) { 144 out.print(" class=\"" + cSSClass + "\""); 145 } 146 if (cSSID != null) { 147 out.print(" id=\"" + cSSID + "\""); 148 } 149 150 out.print(" action=\"" + action + "\" method=\"" + method + "\""); 151 152 if (encoding != null) { 153 out.print(" enctype=\"" + encoding + "\""); 154 } 155 156 out.println(">"); 157 158 HtmlElement oneElement = null; 159 160 for (Enumeration e = contents.elements(); e.hasMoreElements();) { 161 oneElement = (HtmlElement) e.nextElement(); 162 oneElement.display(out, depth + 1); 163 } 164 165 this.padWithTabs(out, depth); 166 out.println("</form>"); 167 setDisplayed(); 168 } 169 170 171 178 public void setAction(String newAction) 179 throws HtmlException { 180 action = newAction; 181 } 182 183 184 191 public void setEncoding(String newEncoding) 192 throws HtmlException { 193 encoding = newEncoding; 194 } 195 196 197 203 public void setMethod(String newMethod) 204 throws HtmlException { 205 String myName = (thisClass + "setMethod(String)"); 206 207 if (newMethod == null) { 208 throw new HtmlException(myName + ":Method must be specified for " + 209 getName()); 210 } 211 212 method = newMethod; 213 } 214 215 216 } 217 218 | Popular Tags |