Skip to main content

Command Palette

Search for a command to run...

Spring ViewComponent v0.7.0 release

Updated
Spring ViewComponent v0.7.0 release
T

Thomas Schühly’s server-side rendering journey started as a developer trying to make life easier while developing his first bootstrapped product in his free time. Creating Spring ViewComponent enabled him to be the youngest Speaker at the largest European Spring conference and build awesome software full-time with his open-source library at alanda.io. He regularly talks at Java User Groups about htmx and server-side rendering with Spring while contributing to the open-source community. PhotoQuest

I'm excited to announce the release of Spring ViewComponent v0.7.0 today.

You can grab the release from Maven Central by following the instructions at: https://github.com/tschuehly/spring-view-component#installation

The two biggest changes to this release are the annotation processor for processing ViewComponents at build time and an improved way to create a ViewContext.

Annotation Processor

Previously the templates were processed at request time by parsing them with jsoup and then transforming the view:action attributes after rendering the templates was finished.

This was complicated as we needed to deal with HTML parsing and figuring out what ViewComponent the view:action attribute was in and severely impacted performance, as this was done on each request and not just once.

Now a Java annotation processor will process the templates at build time to translate the view:action attributes to hx- attributes.

But hot reloading the templates also still works as I integrated a Spring Devtools FileSystem Watcher to parse the templates at development time.

Creating a ViewContext

Previously we created a ViewContext by calling the ViewContext constructor and passing ViewProperties.

This will now be replaced by creating a dedicated record that needs to implement the ViewContext interface. This will enable type checking of templates in the future.

This simplifies the @param annotation inside JTE templates and the @thymesVar comment inside Thymeleaf templates immensely!

If you have any questions just open an issue in the GitHub Repository!

If you want to learn more about HTMX + Spring Boot check out my series Web development without the JavaScript headache with Spring + HTMX.

My side business PhotoQuest is also built with HTMX + JTE

More from this blog

Thomas Schilling | Spring/HTMX/Claude Code

22 posts

Youngest Speaker @Spring I/O & Spring ViewComponent creator.

Passionate about building awesome software with Spring + HTMX. Pushing full-stack development with Spring forward.