1 29 30 package nextapp.echo2.webcontainer; 31 32 import java.io.IOException ; 33 34 import org.w3c.dom.Element ; 35 36 import nextapp.echo2.app.ApplicationInstance; 37 import nextapp.echo2.webrender.BaseHtmlDocument; 38 import nextapp.echo2.webrender.Connection; 39 import nextapp.echo2.webrender.ContentType; 40 import nextapp.echo2.webrender.Service; 41 import nextapp.echo2.webrender.WebRenderServlet; 42 import nextapp.echo2.webrender.output.CssStyle; 43 import nextapp.echo2.webrender.service.CoreServices; 44 45 49 public class WindowHtmlService 50 implements Service { 51 52 public static final WindowHtmlService INSTANCE = new WindowHtmlService(); 53 54 57 public static final String ROOT_ID = "c_root"; 58 59 62 public String getId() { 63 return WebRenderServlet.SERVICE_ID_DEFAULT; 64 } 65 66 69 public int getVersion() { 70 return DO_NOT_CACHE; 71 } 72 73 76 public void service(Connection conn) throws IOException { 77 ContainerInstance ci = (ContainerInstance) conn.getUserInstance(); 78 conn.setContentType(ContentType.TEXT_HTML); 79 80 boolean debug = !("false".equals(conn.getServlet().getInitParameter("echo2.debug"))); 81 82 BaseHtmlDocument baseDoc = new BaseHtmlDocument(ROOT_ID); 83 baseDoc.setGenarator(ApplicationInstance.ID_STRING); 84 baseDoc.addJavaScriptInclude(ci.getServiceUri(CoreServices.CLIENT_ENGINE)); 85 86 baseDoc.getBodyElement().setAttribute("onload", "EchoClientEngine.init('" + ci.getServletUri() + "', " 88 + debug + ");"); 89 90 Element bodyElement = baseDoc.getBodyElement(); 91 92 CssStyle cssStyle = new CssStyle(); 94 cssStyle.setAttribute("position", "absolute"); 95 cssStyle.setAttribute("font-family", "verdana, arial, helvetica, sans-serif"); 96 cssStyle.setAttribute("font-size", "10pt"); 97 cssStyle.setAttribute("height", "100%"); 98 cssStyle.setAttribute("width", "100%"); 99 cssStyle.setAttribute("padding", "0px"); 100 cssStyle.setAttribute("margin", "0px"); 101 cssStyle.setAttribute("overflow", "hidden"); 102 bodyElement.setAttribute("style", cssStyle.renderInline()); 103 104 baseDoc.render(conn.getWriter()); 106 } 107 } 108 | Popular Tags |