jochen777 / jWebForm

Java WebForm Library: HTML Form generation and validation
MIT License
17 stars 2 forks source link

Thymeleaf integration? #3

Open odrotbohm opened 6 years ago

odrotbohm commented 6 years ago

As Thymeleaf is the most popular template engine with Spring application these days it would be cool if there was some documentation about how to use jWebForm with it. Maybe a very thin Thymeleaf dialect that allows the declaration as follows:

<form th:web-form="${form}" />

That could hide away the interaction with the jWebForm APIs in the controller.

jochen777 commented 6 years ago

Please have a look at this demo project, that uses thymeleaf and spring-boot-2:

Controller: https://github.com/jochen777/jWebFormSpringBoot2Thymeleaf/blob/master/src/main/java/com/example/springboot2thymeleaf/demo_thymeleaf/web/DemoController.java (I even wrote a unit-test for this! :)

Template: https://github.com/jochen777/jWebFormSpringBoot2Thymeleaf/blob/master/src/main/resources/templates/demo.html

Do you think, that this is clean enough? I don't want to dive too deep into Thymeleaf, if possible. (But to be honest: The rendering in java is mostly not the best way. It is better located in the template engine. BUT this can be done in a central, generic way and have to be done just once for all forms)

n8himmel commented 4 months ago

I think this one is ready to close :-)

dsyer commented 4 months ago

The sample is for an old unsupported version of Spring Boot. I couldn't run it with Spring Boot 3.3. It isn't anyway referenced in the docs for this project, so I would say the issue is still open.