The HTML classes in the com-hfg library are designed to let you construct complex html content for web applications in a modular, object-oriented way. This approach can be used in conjunction with javascript frameworks by constructing complex panels or forms on the server side and deploying them via AJAX. Say goodbye to unbalanced tags or html typos!
would produce the following HTML:
- HTMLDoc htmlDoc = new HTMLDoc();
- HTML html = (HTML) htmlDoc.getRootNode();
- html.getBody().addDiv("Hello World");
- htmlDoc.toIndentedHTML(3, 3, response.getWriter());
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <title>Untitled Document</title>
- <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
- </head>
- <body>
- <div>Hello World</div>
- </body>
- </html>
- public HTMLTag generateSimpleTable()
- {
- Table table = new Table().addClass("myTableClass");
- Tr row = table.addRow();
- row.addCell("BOLD text").addStyle(CSS.BOLD);
- row.addCell().addSpan("span in a cell");
- return table;
- }