DandelionServlet is not being invoked

227 views Asked by At

Here is my problem. I'm trying to setup dandelion datatable on my Spring-boot Thymeleaf application. I believe I have everything wired correctly. I can take the javascript file from the AssetCacheManger that's in the logs and manually invoke the DandelionServlet from the URL, but it is not being invoke automatically as in the examples on GitHub. Also note I have Spring Security installed. Before posting I disabled security to make sure that wasn't an issue.

POM

<dependency> <groupId>com.github.dandelion</groupId> <artifactId>datatables-thymeleaf</artifactId> <version>0.10.0</version> </dependency>

JavaConfig

@Configuration
public class DandelionConfig
{
    @Bean
    public DandelionDialect dandelionDialect()
    {
        return new DandelionDialect();
    }

    @Bean
    public DataTablesDialect dataTablesDialect()
    {
         return new DataTablesDialect();
    }

    @Bean
    public FilterRegistrationBean dandelionFilterRegistrationBean()
    {
         FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
         DandelionFilter dandelionFilter = new DandelionFilter();
         filterRegistrationBean.setFilter(dandelionFilter);
         return filterRegistrationBean;
    }

    @Bean
    public ServletRegistrationBean dandelionServletRegistrationBean()
    {
         ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
         DandelionServlet dandelionServlet = new DandelionServlet();
         servletRegistrationBean.setServlet(dandelionServlet);
         servletRegistrationBean.addUrlMappings("/dandelion-assets/*");
         return servletRegistrationBean;
    }
 }

Here is the log portion that differs from the GitHub examples. No location found for delegate on AssetMapper

2015-06-17 12:57:51,503 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.datatables.core.configuration.DatatablesConfigurator - Initializing the Javascript generator...
2015-06-17 12:57:51,508 Application: LMI [http-apr-8080-exec-7] WARN  com.github.dandelion.core.asset.AssetMapper - No location found for delegate on AssetStorageUnit [name=dandelion-datatables, version=0.10.0, type=js, dom=null, locations={delegate=dandelion-datatables.js}, attributes=null, attributesOnlyName=[]]
2015-06-17 12:57:51,513 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.core.asset.cache.AssetCacheManager - Retrieving asset with the key 591a4c961431b5fb3c6eedecfc5cca1b6ea5b09d/dandelion-datatables-0.10.0.js
2015-06-17 12:57:51,513 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.core.asset.cache.AssetCacheManager - Storing asset under the key 591a4c961431b5fb3c6eedecfc5cca1b6ea5b09d/dandelion-datatables-0.10.0.js
2015-06-17 12:57:51,518 Application: LMI [http-apr-8080-exec-7] WARN  com.github.dandelion.core.asset.AssetMapper - No location found for delegate on AssetStorageUnit [name=dandelion-datatables, version=0.10.0, type=js, dom=null, locations={delegate=dandelion-datatables.js}, attributes=null, attributesOnlyName=[]]
2015-06-17 12:57:51,518 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.core.asset.cache.AssetCacheManager - Retrieving asset with the key 591a4c961431b5fb3c6eedecfc5cca1b6ea5b09d/dandelion-datatables-0.10.0.js
2015-06-17 12:57:51,518 Application: LMI [http-apr-8080-exec-7] DEBUG com.github.dandelion.core.asset.cache.AssetCacheManager - Storing asset under the key 591a4c961431b5fb3c6eedecfc5cca1b6ea5b09d/dandelion-datatables-0.10.0.js

Thanks,

2

There are 2 answers

0
ndrone On BEST ANSWER

I created a simple Spring Boot application using Thymeleaf and Dandelion-datatables.

You can get the code here https://github.com/ohiocowboy/datatable-thymeleaf-spring-boot-starter

0
Faraj Farook On

With reference to this answer

Spring Boot + Thymeleaf + Dandelion configuration not working


Can you use this config instead

@Configuration
public class DandelionConfig {

    @Bean
    public DandelionDialect dandelionDialect() {
        return new DandelionDialect();
    }

    @Bean
    public DataTablesDialect dataTablesDialect(){
        return new DataTablesDialect();
    }

    @Bean
    public Filter dandelionFilter() {
        return new DandelionFilter();
    }

    @Bean
    public ServletRegistrationBean dandelionServletRegistrationBean() {
        return new ServletRegistrationBean(new DandelionServlet(), "/dandelion-assets/*");
    }
}

along with these dependencies

<dependency>
    <groupId>com.github.dandelion</groupId>
    <artifactId>datatables-thymeleaf</artifactId>
    <version>0.10.1</version>
</dependency>
<dependency>
    <groupId>com.github.dandelion</groupId>
    <artifactId>datatables-spring3</artifactId>
    <version>0.10.1</version>
</dependency>