1 14 package org.compiere.www; 15 16 import java.io.*; 17 import org.apache.ecs.xhtml.*; 18 19 25 public class WDoc 26 { 27 32 public static WDoc create (boolean plain) 33 { 34 WDoc doc = new WDoc(); 35 doc.setUp (plain); 36 return doc; 37 } 39 44 public static WDoc create (String title) 45 { 46 WDoc doc = WDoc.create(false); 47 doc.setTitle (title); 48 return doc; 49 } 51 52 53 56 private WDoc () 57 { 58 } 60 private html m_html = new html(); 61 private head m_head = new head(); 62 private body m_body = new body(); 63 64 68 protected void setUp (boolean plain) 69 { 70 m_html.addElement(m_head); 71 m_html.addElement(m_body); 72 if (!plain) 73 { 74 m_head.addElement(new link().setRel("stylesheet").setHref(WEnv.getStylesheetURL())); 75 script std = new script("", WEnv.getBaseDirectory("standard.js")); 76 m_head.addElement(std); 77 m_body.addElement(WEnv.getLogo()); 78 } 79 } 81 85 protected void setTitle (String title) 86 { 87 if (title == null) 88 return; 89 90 m_head.addElement(new title(title)); 91 m_body.addElement(new h1(title)); 92 } 94 98 public body getBody() 99 { 100 return m_body; 101 } 103 107 public head getHead() 108 { 109 return m_head; 110 } 112 116 public String toString() 117 { 118 return m_html.toString(); 119 } 121 125 public void output (OutputStream out) 126 { 127 m_html.output(out); 128 } 130 134 public void output (PrintWriter out) 135 { 136 m_html.output(out); 137 } 139 140 141 145 public static void main (String [] args) 146 { 147 WDoc doc = WDoc.create("Test"); 148 System.out.println(doc.toString()); 149 System.out.println("---------"); 150 doc.output(System.out); 151 152 } } | Popular Tags |