0

I am using dandalion datatables with my spring project. I want to export my datatables grid to pdf,excel etc.

So I started with PDF

As per this link

I followed the steps one by one.

Step 1 : Added jar files

datatables-export-itext-0.10.0.jar
datatables-export-poi-0.10.0.jar
datatables-export-poi-ooxml-0.10.0.jar
itext-1.3.jar

Step 2 : Web.xml Filter adding

 <!-- Dandelion-Datatables filter definition (used for export) -->
<filter>
    <filter-name>datatablesFilter</filter-name>
    <filter-class>com.github.dandelion.datatables.extras.servlet2.filter.DatatablesFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>datatablesFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

And in jsp

 <datatables:table id="roles" data="${list}" cssClass="table table-striped" pageable="true" displayLength="5" filterable="true" processing="true" autoWidth="true" export="pdf">
  <datatables:column title="Id" property="roleId" />
  <datatables:column title="Role" property="role" />
  <datatables:export type="pdf" cssClass="btn btn-small" />
 </datatables:table>

But I am getting following error.

java.lang.ClassNotFoundException: com.github.dandelion.datatables.core.export.ExportPropertiesat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206) at com.github.dandelion.datatables.extras.servlet2.filter.DatatablesFilter.doFilter(DatatablesFilter.java:88) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.github.dandelion.core.web.DandelionFilter.doFilter(DandelionFilter.java:157) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org....

What am I missing??

Please provide any help. Thanks in advance.

tduchateau
  • 4,351
  • 2
  • 29
  • 40
prem30488
  • 2,828
  • 2
  • 25
  • 57

2 Answers2

1

Starting from the v0.10.0, the installation steps have changed and the datatables-servlet2 extra, in which leaved the old DatatablesFilter class you've mentionned, no longer exist.

First of all, ensure to have declared all needed components in your web.xml file, especially DandelionFilter and DandelionServlet. Installation guides here. A migration guide from 0.9.x to 0.10.x has also been written.

Regarding the export features, it seems you've preferred the filter-based export. In this situation, you have to update your web.xml file as well:

<!-- Dandelion-Datatables filter used for basic export -->
<filter>
    <filter-name>datatables</filter-name>
    <filter-class>com.github.dandelion.datatables.core.web.filter.DatatablesFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>datatables</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping> 

Read more here about the requirements when using filter-based exports.

By default, the datatables-core JAR provides utility classes for XML and CSV formats. If you want to export in PDF, XLS or XLSX formats, other utilities exist, located in different extras. See the new introduction about export feature here.

Of course, in order to avoid any other dependency issue, I strongly recommend to use a build tool, such as Maven or Gradle.

(Disclaimer required by StackOverflow: I'm the author of Dandelion)

tduchateau
  • 4,351
  • 2
  • 29
  • 40
  • Sir I changed web.xml as you mensioned now my error is `com.github.dandelion.datatables.core.exception.ExportException: Unable to export in the pdf format because the export class com.github.dandelion.datatables.extras.export.itext.PdfExport is not present in the classpath. Did you forget to add a dependency?` But I have `datatables-export-itext-0.10.0.jar` in my lib folder.... can u plz guide me??? Great thanks to you... – prem30488 Jun 02 '14 at 11:18
  • Could you please turn the DEBUG log level on and post the result? It may be more practical to open a new topic in the [forum](http://dandelion-forum.48353.x6.nabble.com/). :-) – tduchateau Jun 02 '14 at 11:27
  • sir your forum link is blocked in our office cyberorm. com.github.dandelion.datatables.core.exception.ExportException: Unable to export in the pdf format because the export class com.github.dandelion.datatables.extras.export.itext.PdfExport is not present in the classpath. Did you forget to add a dependency? at com.github.dandelion.datatables.core.export.ExportDelegate.prepareExport(ExportDelegate.java:92) at com.github.dandelion.datatables.jsp.tag.AbstractTableTag.setupExport(AbstractTableTag.java:277) at com.github.dandelion.datatables.jsp.tag.TableTag.doEndTag(TableTag.java:139) – prem30488 Jun 02 '14 at 11:32
  • sir it got solved by adding `itextpdf-5.5.1.JAR`.. thank you for your guidance... – prem30488 Jun 02 '14 at 12:01
  • Great! I really suggest you to use a build tool ;-) – tduchateau Jun 02 '14 at 14:06
  • sir i have another problem in I18n please see http://stackoverflow.com/questions/24011927/dandalion-datatables-i18n-spring-resolver-not-working – prem30488 Jun 03 '14 at 09:45
0

looks like the datatables-core-x.y.z.jar is missing in your classpath.

Jens
  • 67,715
  • 15
  • 98
  • 113
  • I think some properties are missing... but I do not know exactly what is missing... I made `datatables-default.properties` file in res folder and added global.export.pdf.class=com.github.dandelion.datatables.extras.export.itext.PdfExport But still no luck.... Getting same error.... :( – prem30488 Jun 02 '14 at 09:53
  • 1
    Looks like the class is not exisition in version 0.10.0. In version 0.9.3 is is the core.jar. Try the older version. – Jens Jun 02 '14 at 10:02
  • I added 0.9.3 and error changed to java.lang.NullPointerException at com.github.dandelion.datatables.extras.servlet2.filter.DatatablesFilter.doFilter(DatatablesFilter.java:88) – prem30488 Jun 02 '14 at 10:19