Replies: 1 comment 2 replies
-
You might want to take a look at Spring ViewComponent: https://github.com/tschuehly/spring-view-component by @tschuehly |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
HTMX seems to work best if the initial page is served in it's full extent. But there are parts of the page which can be defined best as separate controllers, for example a table view with all it's CRUD interactions.
Currently it's possible to include the table's template on Thymeleaf level into the main page's template, but the controller serving the page has to be aware of the model attributes and dependencies required for table which creates duplication, pollutes the controller and makes re-usability and modularization hard.
A better approach would be to be able to call the other Controller dealing with the table as part of the current template render so it can be in-lined, but it can be also called normally by HTMX if a partial refresh of the DOM required for that element. This creates a clear separation but also allows optimal rendering when the full page is requested. (something similar can be emulated with hx-trigger="load" and hx-get as discussed here)
I can imagine a Thymeleaf dialect extension like:
<hx:controller-get path="/view/table"/>
This will find the Controller method matching the path, call it inline with the current request and inline/merge the response into the template.
What do you think? I'm toying with the idea of giving this a shot implementing it.
Beta Was this translation helpful? Give feedback.
All reactions