Viking
Viking

Reputation: 177

How create table use j2html?

I get acquainted with j2html and I try a make table, but have some problems:

  main().with(
                    table(

                            tr(
                                    td().with(
                                            img().withSrc(imagePath+photo)

                                    )

                                    td().with(
                                            span(name)
                                    ),
                                    td().with(
                                            span(String.valueOf(quantity))
                                    )

after img().withSrc(imagePath+photo) I see mistake, but I don't understand what want from me Idea May be you can show how create table with image+name+ some quontity + colspan for several cells

Upvotes: 2

Views: 3066

Answers (1)

tipsy
tipsy

Reputation: 402

(pre v.1.0.0): The tag-methods don't accept DomContent children, so you need to do table().with(, td().with( etc, not just table( and td(:

String htmlTable = table().with(
    tr().with(
        td().with(
            img().withSrc("path" + "photo")
        ),
        td().with(
            span("name")
        ),
        td().with(
            span(String.valueOf("quantity"))
        )
    )
).render();

Upvotes: 3

Related Questions