I use Displaytag for displaying data in an as400 Work-With Subfile type format in web pages, and it works very well.
One problem I came across was formatting the dates, whilst still using the automatic sorting. I thought I would have to format my data in my POJO and lose the automatic sorting.
But in fact Displaytag solves this problem by allowing you to apply decorators to columns
eg:
package com.decorator;
import java.util.Date;
import org.apache.commons.lang.time.FastDateFormat;
import org.displaytag.decorator.ColumnDecorator;
/**
* Simple column decorator which formats a date.
* @author epesh
* @author Fabrizio Giustina
* @version $Revision: 1.11 $ ($Author: fgiust $)
*/
public class DatetoDMY implements ColumnDecorator
{
/**
* FastDateFormat used to format the date object.
*/
private FastDateFormat dateFormat = FastDateFormat.getInstance("dd.MM.yyyy HH:mm:ss"); //$NON-NLS-1$
/**
* transform the given object into a String representation. The object is supposed to be a date.
* @param columnValue Object
* @return String
*/
public final String decorate(Object columnValue)
{
Date date = (Date) columnValue;
return this.dateFormat.format(date);
}
}
Thursday, December 09, 2004
Subscribe to:
Post Comments (Atom)
Popular Posts
- Linux Forum: Apache, Webmin and Mandrake - Linux Operating System Help
- Yahoo! Mail: Revenge of the Oddpost
- Free AS400 & iSeries Software Tools & Utilities Downloads
- Fast-track your Web apps with Ruby on Rails
- The Laughing Boardroom video...a real world example!
- Basic Requirements of a JavaServer Faces Application
- UDATE and *DATE in AS400 RPG
- IBM eServer iSeries - The Laughing Boardroom
- Creating an as400 Query
- AS400 APIs
uhh...hi
ReplyDeletehow to use this ?
how to use what, displaytag or the decorator?
ReplyDelete