1 29 30 package nextapp.echo2.webrender; 31 32 import java.util.Properties ; 33 import javax.xml.transform.OutputKeys ; 34 import org.w3c.dom.Document ; 35 import org.w3c.dom.Element ; 36 37 import nextapp.echo2.webrender.output.HtmlDocument; 38 39 42 public class BaseHtmlDocument extends HtmlDocument { 43 44 47 private static final Properties OUTPUT_PROPERTIES = new Properties (); 48 static { 49 OUTPUT_PROPERTIES.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); 51 52 OUTPUT_PROPERTIES.setProperty(OutputKeys.DOCTYPE_PUBLIC, XHTML_1_0_TRANSITIONAL_PUBLIC_ID); 53 OUTPUT_PROPERTIES.setProperty(OutputKeys.DOCTYPE_SYSTEM, XHTML_1_0_TRANSITIONAL_SYSTSEM_ID); 54 } 55 56 private String contentId; 57 58 64 public BaseHtmlDocument(String contentId) { 65 super(XHTML_1_0_TRANSITIONAL_PUBLIC_ID, XHTML_1_0_TRANSITIONAL_SYSTSEM_ID, XHTML_1_0_NAMESPACE_URI); 66 setOutputProperties(OUTPUT_PROPERTIES); 67 this.contentId = contentId; 68 Document document = getDocument(); 69 70 Element styleElement = document.createElement("style"); 71 styleElement.setAttribute("type", "text/css"); 72 styleElement.appendChild(document.createTextNode(" ")); 73 getHeadElement().appendChild(styleElement); 74 75 Element formElement = document.createElement("form"); 76 formElement.setAttribute("style", "padding:0px;margin:0px;"); 77 formElement.setAttribute("action", "#"); 78 formElement.setAttribute("id", contentId); 79 formElement.setAttribute("onsubmit", "return false;"); 80 81 Element loadingDiv = document.createElement("div"); 82 loadingDiv.setAttribute("id", "loadstatus"); 83 loadingDiv.appendChild(document.createTextNode("//")); 84 formElement.appendChild(loadingDiv); 85 86 getBodyElement().appendChild(formElement); 87 } 88 89 95 public Element getContentElement() { 96 return getDocument().getElementById(contentId); 97 } 98 } 99 | Popular Tags |