Skip to main content

Posts

Using YUI3 Panel to send server transaction request from client-side

This article presents a nice way how to save some user-defined input on server and make browser wait for it before proceeding with navigation. This will be shown in a context of my use case that consists in a Cocoon Java application that allows exporting page in PDF format. Exported page is being generated by a specific Java Servlet as soon as the client browser redirects to the corresponding URL. Now assume that the end user wants to set a custom title for the exported page. Thus, we need some kind of interruption when the user clicks on the 'Export' link. It'll be implemented using nice YUI3-based Transaction utility and YUI3 Panel shown below:
Initialize YUI3
To get started with YUI3, you should perform two steps:
Load the YUI javascript file on your web page.Create and configure a new YUI instance. Please refer to this manual for code snippets. The only difference is that we'll use two modules: io and panel. Module io is required for transaction utility that will b…

Selecting date range with YUI3 Calendar

This is a fully UI related article about YUI3 Calendar widget. Whereas official documentation page and provided examples (here and here) are good enough to start with, there are still many pitfalls when you're going to customize the widget. My use case required a date range selection feature with a nice calendar window open only when a user clicks on text input fields. Also the selected day should be highlighted in the calendar whenever a user clicks again on the filled text input field (a nice example with YUI2 Calendar widget). This is how one date input field looks like:
Add calendar container and date fields on the web page
First of all you need to add a container div for the calendar: <div id="calendar-container"> </div> You will provide this id to the Calendar constructor later either as a bounding box or a content box. The difference is in html markup generated by YUI3. I'll use a bounding box below in order to manipulate position of calendar wind…

How to efficiently cache static resources in a web application

This article is about an efficient technique of caching static resources on the client side (user's browser). There are quite many ways to implement caching including HTTP headers. A common disadvantage of them is that as soon as some resource is cached by the browser, it won't be updated until it's expired. Thus, the server loses control over the browser caching mechanism for some period of time. As a result we have to adjust the expiration time period or updating frequency somehow.

The better alternative is the case when it's only the server that is in charge of the browser caching mechanism. Actually the idea has been borrowed here. If we append a GET parameter with some changing value (like a timestamp or a version) for a static resource URL, it'll force the browser to get the fresh version of the resource from the server. If we keep the parameter value steady, the resource will be taken from the browser cache.

Finally this article is about implementation. I h…

DynamicReports and Cocoon integration

This is one more tutorial on how to exploit DynamicReports reporting library in an existing web application. This time the application is based on Cocoon 2.2 framework. This post is a continuation to the previous posts: Choosing Java reporting tool - part 2 and DynamicReports and Spring MVC integration. The complete code won't be provided here but only the essential code snippets together with usage remarks.
First of all I'm writing the plan of this how to:
Description of existing application data flow.Adding project dependencies.Implementing export servlet.Implementing XSLT extension for the export data source.Implementing XSLT for postprocessing.Modifying JX template.Modifying Cocoon sitemap.Description of existing application data flow
Cocoon framework organizes data flow using the concept of pipelines. For details please refer to Cocoon documentation. My application uses the following component sequence in a pipeline:
Standard JX template generator produces xquery code.Cust…

DynamicReports and Spring MVC integration

This is a tutorial on how to exploit DynamicReports reporting library in an existing Spring MVC based web application. It's a continuation to the previous post where DynamicReports has been chosen as the most appropriate solution to implement an export feature in a web application (for my specific use case). The complete code won't be provided here but only the essential code snippets together with usage remarks. Also I've widely used this tutorial that describes a similar problem for an alternative reporting library.
So let's turn to the implementation description and start with a short plan of this how-to:
Adding project dependencies.Implementing the Controller part of the MVC pattern.Modifying the View part of the MVC pattern.Modifying web.xml.Adding project dependencies
I used to apply Maven Project Builder throughout my Java applications, thus the dependencies will be provided in the Maven format.

Maven project pom.xml file:
net.sourceforge.dynamicreportsdynamicrepo…

Choosing Java reporting tool - part 2

I've provided a general overview of possible solutions to get a reporting/exporting functionality in the previous post. This is the second overview of alternatives based on JasperReports reporting engine.

Since the previous part I've done the following:
Implemented a simple report using both DynamicJasper and DynamicReports to compare them from technical side.Investigated JasperServer features and tried to implement a simple report for JasperServer instance (it appeared we already have a ready licensed installation of JasperServer that makes it unreasonable to install a fresh one).
First, the comparison results of Java libraries (DynamicJasper and DynamicReports):
Both libraries suffer from poor-quality or missing Java docs but they look a bit better in DynamicJasper.Taking into account the point 1, a developer has to use online documentation and to review the code. Here the code looks definitely nicer and more readable for DynamicReports. With respect t…

Choosing Java reporting tool

My current goal is to obtain an universal solution to be able to export application data in any format I'd prefer. Mainly it includes exporting tables with various data.

I've done an overview and have considered the following alternatives: Own implementation.
Here I mean implementation of own Java library that will accept some abstract data (say, valuelist) and will perform export using known open-source libraries (MS Office Excel - Apache POI, PDF - itext, etc). This is the way we've already used at work before.

The critical disadvantage of this proposal is that much efforts will be required.
Existing solution.
This is also known as reporting engine software.

Main points: JasperReports is the most popular open-source reporting engine.There are 3 ways to use it:JasperReports API - gives complete control on report creation but is extremely complex.Different visual report designers (e.g. iReport) - allows creating report templates manually.Software tools that use JasperRepo…