Thymeleaf dialect with RequireJS?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Thymeleaf dialect with RequireJS?

I have tried to use Dandelion Datatables with Thymeleaf. It works, but, I'm also using RequireJS in my project, to accomplish with AMD design, and keeps things organized.

The problem I had is that the inline auto-generated script from Dandelion Datatables is not compliant with AMD modular design.
So, when the script loads, it says $ is not defined (because it would have to add a require['jquery'] before using it).
I have tried to circumvent this problem using the "extra javascript files"  so I could add the proper require statements at the beginning of the javascript generation, but it looks like this is not supported for thymeleaf.

Any recommendation on how to do that? Or maybe RequireJS + Thymeleaf is not supported by Dandelion Databales yet?

Reply | Threaded
Open this post in threaded view

Re: Thymeleaf dialect with RequireJS?

Thibault Duchateau

First of all, I have taken the liberty of moving your topic to the Dandelion Core forum, hope you'll understand why.

Prior to the v0.10.0, <script> and <link> tags were generated by Dandelion-Datatables and in different ways, depending on the template engine.
JSP: just before and after the generated  tag, mainly because the JSP technology can be seen as sequential text processing and prevents us from accessing the DOM tree.
Thymeleaf: <script> and <link> tags were respectively injected at the end of the <body> and at the end of the <head> tag, but still with some limitations: Thymeleaf doesn't always give access to the full template, for example when using templating libraries such as Apache Tiles or the Layout dialect.

Starting from the v0.10.0, <script> and <link> tags generation are the Dandelion Core responsibility. Actually it proposes a new approach to deal with assets, their loading and dependencies management: thanks to asset bundles. These bundles (which will be fully documented soon) bring a kind of new abstraction layer, somewhat like Maven with its POM which is used to declare server-side dependencies used inside your project.  

So unfortunately, Dandelion v0.9.x and v0.10.0 (Core and Datatables) doesn't support RequireJS or more generally speaking, AMD modular design, but will propose an alternative. However, once the v0.10.0 released, I'd be happy to discuss about it for future versions.