This post began as a look at handling a Java Date value across the various application layers of NixMash Spring v0.1.5, with Dandelion being part of the mix. Then I felt it better to look at Dandelion separately to get the party started. The Contact Update form with the Date field in which Dandelion plays a part is shown below.
Let’s begin by looking at the Dandelion dependencies in our Gradle build.gradle file. (Last two compile entries.)
Dandelion is currently at 1.0.1, but if you look at the two com.github.dandelion entries above you’ll notice I’m using 0.10.1. Dandelion configuration is different in 1.x.x, and I wish I could give you the details on setting up the latest and greatest Dandelion in Spring Boot. Unfortunately, after 4 hours or so of inexplicable 500 Internal Server errors using various 1.0.1 configurations I threw in the towel and went back to 0.10.1. I’ll try again after a couple more Dandelion releases and get back to you.
The datatables-thymeleaf library is all we need to get started, but we’ll be retrieving our JS and CSS assets from Webjars, so we need the dandelion-webjars library as well. Displayed above our Dandelion dependencies are two new Webjars: jQuery-UI and jQuery-UI-Themes. Dandelion is going to retrieve assets from those webjars to generate our form’s Contact BirthDate Calendar.
Below is a simple DandelionConfig Spring @Configuration file where we create the Dandelion Beans for the Servlet, its Filter and Dialect.
I mentioned Dandelion’s tight integration with Thymeleaf, so to enjoy that integration we need to add the DandelionDialect bean to our SpringTemplateEngine bean.
Dandelion Asset Bundles
As I said a couple of times now, one of the cool features of Dandelion is its use of Asset Bundles. Still in the Thymeleaf HTML file, here’s the Contact BirthDate field where we load up the jquery-ui-overcast bundle.
Our Asset Bundle is a JSON Resource file as you see in the Project Window layout.
The Dandelion Asset Bundle file defines the bundle, lists any dependencies and then lists the assets to be loaded. We’re using the jQuery-UI JS file and the jQuery-UI Overcast Theme CSS file. Again, both from their respective Webjars, so very cool stuff.
That pretty much wraps up getting started with Dandelion in Spring. Next time we’ll look at handling that pesky BirthDate value. Don’t worry, with Spring MVC and Hibernate annotations it’ll be a cinch!