| 36 | import org.xmlet.htmlapifaster.Tbody; |
| 37 | |
| 38 | public class HtmlDynamic { |
| 39 | |
| 40 | public static HtmlView stocksViewOk = HtmlFlow.view(HtmlDynamic::templateStocksOk); |
| 41 | |
| 42 | private static void templateStocksOk(HtmlPage page) { |
| 43 | page |
| 44 | .html() |
| 45 | .head() |
| 46 | .title().text("Stock Prices").__() |
| 47 | .meta() |
| 48 | .attrHttpEquiv(EnumHttpEquivType.CONTENT_TYPE) |
| 49 | .attrContent("text/html; charset=UTF-8") |
| 50 | .__() |
| 51 | .meta() |
| 52 | .addAttr("http-equiv", "Content-Style-Type") |
| 53 | .attrContent("text/CSS") |
| 54 | .__() |
| 55 | .meta() |
| 56 | .addAttr("http-equiv", "Content-Script-Type") |
| 57 | .attrContent("text/javascript") |
| 58 | .__() |
| 59 | .link() |
| 60 | .addAttr("rel", "shortcut icon") |
| 61 | .attrHref("/images/favicon.ico") |
| 62 | .__() |
| 63 | .link() |
| 64 | .attrRel(EnumRelType.STYLESHEET) |
| 65 | .attrType(EnumTypeContentType.TEXT_CSS) |
| 66 | .attrHref("/CSS/style.CSS") |
| 67 | .attrMedia(EnumMediaType.ALL) |
| 68 | .__() |
| 69 | .script() |
| 70 | .attrType(EnumTypeScriptType.TEXT_JAVASCRIPT) |
| 71 | .attrSrc("/js/util.js") |
| 72 | .__() |
| 73 | .__() // head |
| 74 | .body() |
| 75 | .h1().text("Stock Prices").__() |
| 76 | .table() |
| 77 | .thead() |
| 78 | .tr() |
| 79 | .th().text("#").__() |
| 80 | .th().text("symbol").__() |
| 81 | .th().text("name").__() |
| 82 | .th().text("price").__() |
| 83 | .th().text("change").__() |
| 84 | .th().text("ratio").__() |
| 85 | .__() // tr |
| 86 | .__() // thead |
| 87 | .tbody() |
| 88 | .<Iterable<Stock>>dynamic((tbody, stocks) -> stocks.forEach(stock -> tableRowView(tbody, stock))) |
| 89 | .__() // tbody |
| 90 | .__() // table |
| 91 | .__() // body |
| 92 | .__(); // html |
| 93 | } |
| 94 | |
| 95 | static final void tableRowView(Tbody<?> tbody, Stock stock) { |