spring-mvcdatatablesservlet-3.0dandelion

How to install dandelion datatables


I am trying to install dandelion datatables and I have some problems with the configuration

Following the guide here I added the following to my pom

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
</dependency>
<dependency>
    <groupId>com.github.dandelion</groupId>
    <artifactId>datatables-jsp</artifactId>
    <version>1.1.0</version>
</dependency>
<dependency>
    <groupId>com.github.dandelion</groupId>
    <artifactId>datatables-export-itext</artifactId>
    <version>1.1.0</version>
</dependency>

Then I added the following to my web.xml file

<!-- Dandelion servlet definition and mapping -->
    <servlet>
        <servlet-name>dandelionServlet</servlet-name>
        <servlet-class>com.github.dandelion.core.web.DandelionServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dandelionServlet</servlet-name>
        <url-pattern>/dandelion-assets/*</url-pattern>
    </servlet-mapping>

<!-- Dandelion filter definition and mapping -->
    <filter>
        <filter-name>dandelionFilter</filter-name>
        <filter-class>com.github.dandelion.core.web.DandelionFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>dandelionFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

I am serving the data from a spring mvc controller to my jsp page where I put the following

<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>

<datatables:table id="myTableId" data="${data}">
    <datatables:column title="ID" property="id" />
</datatables:table>

I am using servlet 3.1 (web.xml below)

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

My container is tomcat 8

PROBLEM

When the table is populated but css and js file are not reachable. The datatable instead works ok but without styling. The pagination however works.

Below some of the link generated that are not reachable.

http://localhost:8080/dtproject/dandelion/datatables/css/jquery.dataTables.css http://localhost:8080/dtproject/dandelion/jquery/js/jquery.js http://localhost:8080/dtproject/dandelion/datatables/js/jquery.dataTables.js

Can anyone help?

Thanks

UPDATE

To tell the engine to load resources from external CDNs I have added the following line to the datatables.properties conf file

asset.locations.resolution.strategy = remote,webapp,webjar,classpath,jar

When I run the program I get this error:

Dandelion: Some properties of your configuration file are not recognized.
The group 'asset' contains 1 unknown property:

Solution

  • I downgraded servlet version from 3.1 to 3.0 and now it works

    Life is strange sometime