Posts Tagged ‘Java’

Add Undo/Redo functionality to a Java app

Tuesday, August 4th, 2009

Recently I had to figure out a way to add undo/redo functionality to an existing Java application. Searching the web for some guidance I got a bit scared by finding posts that gave the impression that undo in Java is an overly complex thing that requires 10+ mysterious classes, best combined with reflection and modified GoF patterns.

I write this post to show you how simple undo in Java is and how it can be easily added to an existing application. You do not need to study Command patterns or rebuild half of your app, just follow the pragmatic approach described below and add a few simple classes to your application!

In our concrete case the requirement was to add undo functionality to an existing Excel-like spreadsheet application that had a horrible menu management and no patterns in it at all. (more…)

Export from Displaytag inside a Portlet

Sunday, December 14th, 2008

The Problem:
When using Displaytag inside a Prortlet, the export functionality will not work because the portlet has no way to produce other than it’s portlet content for display (see http://jira.codehaus.org/browse/DISPL-344).
Since Displaytag export functionality produces downloadable content that the portlet container will interpret as a portlet render result, you will see the Displaytag output as HTML-rubbish.

The Solution:
When we came over this problem, a promising solution seemed to be the one described in this post:  http://www.jroller.com/hakan/entry/liferay_portal_4_1_2,  but nobody was able to get it running.
Based on the concept in this post I came up with the following simple idea: If the problem is, that the output is produced by something inside the portlet, than the solution is to produce the export result outside of the portlet. And it works.

It works like this:

  1. Disable the standard Displaytag export functionality
  2. Create a copy of your page and place it somewhere outside the portlet
  3. Add manually links to the copied page, providing the parameters required by Displaytag

Let’s look at this in detail on a concrete example:

(more…)