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