Introduction

ZK Pivottable is a data summarizing component; taking a flat table as raw data and organizes the data into desired categories arranged by columns and rows. It brings the power of spreadsheet’s pivot table functionality to Java web applications.

This blog post will demonstrate how ZK Pivottable can be used inside a JSP page.

Live Demo

Setting up the environment

Before using ZK Pivottable in your JSP pages, the web application would need some libraries installed. web.xml would also need to be configured to include a special servlet to handle the AJAX interactions with the pivottable component. Please refer to this article for more details.

Embedding Pivottable inside a JSP page

Here is a sample JSP page that uses ZK Pivottable. For brevity, only the relevant lines are shown.

<%@ taglib prefix="zk" uri="http://www.zkoss.org/jsp/zul" %>
...
<body>
<zk:page>
  <zk:window 
      id="win" 
      border="normal" 
      apply="myapp.PivotJspComposer">
    <zk:pivottable id="pivot">
      <zk:div>Mileage</zk:div><%-- Row label %-->
      <zk:div>Destination</zk:div><%-- Column label %-->
      <zk:div>Origin</zk:div><%-- Column label %-->
    </zk:pivottable>
  </zk:window>
</zk:page>
</body>

ZK Pivottable is utilized inside a JSP page via JSP custom tags. Please read here for more information on working with JSP tags defined by ZK.

Embedding ZK Pivottable inside a JSP page is only half the story. Without data, the pivottable is pretty much useless. Hence, a controller class would also need to be written. This article describes what the controller class might look like.

The complete source code for a sample application is available on github.

References

1.

ZK JSP Tags Essentials

2.

ZK Pivottable Essentails


If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

2 Responses to “Using Pivottable inside a JSP page”

  1. Sreevidya says:

    cannot find taglibrary descriptor for “http://www.zkoss.org/jsp/zul”
    Where should I add tag library descriptor?
    am using Spring mvc maven project

  2. Neil Lee says:

    Hello Sreevidya,

    You can insert zuljsp dependency into your maven project by referring to http://books.zkoss.org/wiki/ZK%20JSP%20Tags%20Essentials/Installation.

Leave a Reply