1
j2htmlsを使って各メソッドを使ってコレクションの要素を追加するにはどうすればよいですか?どのようにj2htmlを各メソッドで使うのですか
彼らはhttps://j2html.com/examples.html
// each() lets you iterate through a collection and returns the generated HTML
// as a DomContent object, meaning you can add siblings, which is not possible
// using the stream api in the previous example
body(
div(attrs("#employees"),
p("Some sibling element"),
each(employees, employee ->
div(attrs(".employee"),
h2(employee.getName()),
img().withSrc(employee.getImgPath()),
p(employee.getTitle())
)
)
)
)
に例を与えるしかし、彼らは実際にどのような従業員または従業員を定義していません。
私の場合は、div(各ラベル付き)に一連のCounter要素を追加したいが、それを行う方法がわからないので、今は唯一j2htmlをそれぞれ使用しているし、ハードコードされたタグ。
sb.append("<div>\n");
for(Map.Entry<Integer, Counter> next:fsc.getCounters().entrySet())
{
sb.append(label(next.getValue().getText()).attr("for","pb"+next.getKey().intValue()));
sb.append(render(progress()
.withId("pb"+next.getKey().intValue())
.attr("value", next.getValue().getCounter().intValue())
.attr("max", "100")));
sb.append(rendern(br()));
}
sb.append("</div>\n");