| 36 | import java.util.function.BiConsumer; |
| 37 | |
| 38 | public class HtmlTables { |
| 39 | |
| 40 | public static void simpleTableView(HtmlPage view){ |
| 41 | view |
| 42 | .html() |
| 43 | .head() |
| 44 | .title().text("Dummy Table") |
| 45 | .__()// title |
| 46 | .__()// head |
| 47 | .body() |
| 48 | .h1().text("Dummy Table").__() |
| 49 | .hr().__() |
| 50 | .div() |
| 51 | .table() |
| 52 | .tr() |
| 53 | .th().text("Id1").__() |
| 54 | .th().text("Id2").__() |
| 55 | .th().text("Id3").__() |
| 56 | .__() //tr |
| 57 | .<int[][]>dynamic((table, outputRows) -> { |
| 58 | for (int[] outputRow : outputRows) { |
| 59 | table.tr() |
| 60 | .of(tr -> { |
| 61 | for (int rowValue : outputRow) { |
| 62 | tr.td() |
| 63 | .text("" + rowValue) |
| 64 | .__(); |
| 65 | } |
| 66 | }).__(); |
| 67 | } |
| 68 | }) |
| 69 | .__() |
| 70 | .__() |
| 71 | .__() |
| 72 | .__(); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * An example of a dynamic view with an Iterable<Task> as domain model and |
| 77 | * an array with two partial views: a div heading and table row. |
| 78 | */ |
| 79 | public static HtmlTemplate taskListViewWithPartials(BiConsumer<Tbody<?>, Task> partial) { |
| 80 | return view -> view |
| 81 | .html() |
| 82 | .head() |
| 83 | .title() |
| 84 | .text("Task List") |
| 85 | .__() |
| 86 | .link() |
| 87 | .attrRel(EnumRelType.STYLESHEET) |
| 88 | .attrType(EnumTypeContentType.TEXT_CSS) |
| 89 | .attrHref("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css") |
| 90 | .__() |
| 91 | .__() |
| 92 | .body() |
| 93 | .attrClass("container") |
| 94 | .of(ignore -> // ignore body argument because we don't need it here |
| 95 | HtmlTables.taskListViewHeader(view) |