Questions tagged [j2html]

j2html is a simple type-safe HTML builder library written in Java.

j2html is a Java library for building HTML in a type-safe manner.

The library is designed to be lightweight and fast.

Unlike most template engines, the library relies on chained method calls, e.g.

import static j2html.TagCreator.*;
// ...
String renderedHtml =
    body(
        h1("Hello, World!"),
        img().withSrc("/img/hello.png")
    ).render();
19 questions
10
votes
2 answers

How do I use j2html without rendering everything

I am converting my html rendering code to use j2html. Whilst I like the library it is not easy for me to convert all the code in one go so sometimes I may convert the outer html to use j2html but not able to convert the inner html to j2html at the…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
3
votes
2 answers

Best way to create readable Javascript in Java for adding to html page

I am using j2html to create render html pages via Java, if the html called any javascript function I was putting the Javascript into a separate .js file. However it seems sensible to only include functions is the main application javascript file if…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
3
votes
1 answer

How to use j2html when have a method that needs to return multiple tags?

How to use j2html when have a method that needs to return multiple tags? So here I have a reusable method that constructs a label and inputfield for a particular option. The label is put inside a td and the input field in another td field, all…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
2
votes
1 answer

html umlauts not renderd correctly if progamm executed via jar file

I have the following Java code to create an HTML file. I use the j2html library for that: String html = html( head( meta().attr("charset", "UTF-8"), title("test"), …
randomdev8712
  • 261
  • 1
  • 6
  • 23
2
votes
1 answer

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( …
Viking
  • 177
  • 5
  • 16
1
vote
1 answer

Table borders in j2html

I'm trying to use j2html to produce simple tables for displaying in Swing's TextPanes. I want borders on the table, but I can't figure out how to add the border=1 attribute to the tag (as far as I know, css styles don't work in…
1
vote
1 answer

Where j2html save the HTML file?

I'm using j2html to create an HTML file in Java, it can be a fool question, but where does the file is saved?
Bruno Lopes Bacelar
  • 115
  • 1
  • 2
  • 14
1
vote
0 answers

Rotate Div using J2Html

By using J2Html in JAVA and I need to rotate div (90deg) and it needs to be shown in Binary representation of HTML (Binary Value). This is example of what I've tried so far: ContainerTag test = TagCreator.div().withStyle("transform:…
Brane
  • 3,257
  • 2
  • 42
  • 53
1
vote
1 answer

how to add label using j2html

I am trying to create a login form with j2html,but when try adding label in my form,there is no predefined label exists e.g withId(),withName() private static Tag generateUserField(String user) { return…
1
vote
1 answer

j2html nesting for tables

I am trying to use j2html to render a really simple table, but I have gotten completely stuck on the nesting and can not find any docs for this. Trying to keep this short and to the point, this is the exact html that I want to achieve:
Emily
  • 13
  • 4
1
vote
0 answers

In Java how do I create a structured tree using FileVisitor

Given a starting path I want to create a tree like object representing the filesystem using Java, showing all the folders down to level x but not ordinary files. . So using FileVisitor I know that every time just before Im going to browse a new…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
1
vote
1 answer

How do I use j2html each method

How do I make use of j2htmls each method to add elements of a collection ? They give an example on https://j2html.com/examples.html // each() lets you iterate through a collection and returns the generated HTML // as a DomContent object, meaning you…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
0
votes
0 answers

java 7 j2html unable to load class

I'm trying to use j2html library in my project, but I keep getting this compilation error. Java version: 1.7 Grails Version: 2.4.3 Gradle dependency added: compile 'com.j2html:j2html:1.2.0' Imports: import j2html.tags.ContainerTag import static…
Pawel
  • 417
  • 1
  • 6
  • 25
0
votes
1 answer

Can I use Java Spark Framework to create regular War for deploying in Tomcat

I have happily used Java Spark Framework (& j2html) as part of a standard Java application to provide a browser based UI, this has worked very well. I would now like to build my website using the same technology instead of using Servlet/Jsps as I am…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
0
votes
1 answer

login form sample using j2html

I just tried to create the login form using html in servlet.but I got stuck some place. I'm just using maven dependencies.so I don't have to care about jars. so,let's take a look my main java code package tutor.programacion.primerservlet; import…
rama samy
  • 3
  • 1
1
2