Use a column decorator.

<display:column property="commissionAmount" title="Commission"
decorator="com.whitesandsolutions.gapay.view.decorator.MoneyDecorator"
sortable="true"/>

And create your decorator class something like this:

public class MoneyDecorator implements ColumnDecorator {

        public MoneyDecorator() {
                super();
        }
        
        public String decorate(Object value) {
                String decoratedValue = "";
                try {
                        if(value != null) {
                                // Assumes the value is a Double.
                                decoratedValue =
DataFormatter.formatMoney(((Double)value).toString());
                        }
                } catch (Exception e) {
                        e.printStackTrace();
                        decoratedValue = "Format error.";
                }
                return decoratedValue;
        }
        
}

-----Original Message-----
From: Andy Engle
To: user@struts.apache.org
Sent: 1/6/2005 6:41 PM
Subject: Displaytag, number formatting, and sorting

Hi all,

I am using displaytag, and I would like to have a sortable column of
large numbers.  I want to format these numbers (they're going to be
dollar amounts, like 1,400.00, 6.99, and the like), but it seems that I
cannot have the fancy number formatting and have that column sortable
all at the same time.  I either get a sortable column of numbers that
look like this:

1400.00
33938.39
3450984530.83
.99

...or a non-sortable column of nicely formatted numbers, like this:

1,400.00
33,938.39
3,450,984,530.83
.99

Has anyone been able to get the number formatting and the sorting to
work together?  If so, please tell me what I'm doing wrong.  I've tried
bean:write with a formatKey, html-el:rewrite, and whatever else to no
avail.

Thank you very much!


Andy


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to