The latest version of displaytag supports a sortPropery setting. This allows you to display a nicely formatted value but sort on the underlying data.
Column decorators are very rarely required now. For example: <display:table id="currentRow" ...> <display:column sortProperty="someNumber" ...> <fmt:formatNumber value="${currentRow.someNumber}" type="currency"/> </display:column> </display:table> Paul > -----Original Message----- > From: Barnett, Brian W. [mailto:[EMAIL PROTECTED] > Sent: 07 January 2005 02:00 > To: 'Andy Engle '; 'user@struts.apache.org ' > Subject: RE: Displaytag, number formatting, and sorting > > > 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] > Axios Email Confidentiality Footer Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message, and notify us immediately. If you or your employer does not consent to Internet email messages of this kind, please advise us immediately. Opinions, conclusions and other information expressed in this message are not given or endorsed by my Company or employer unless otherwise indicated by an authorised representative independent of this message. WARNING: While Axios Systems Ltd takes steps to prevent computer viruses from being transmitted via electronic mail attachments we cannot guarantee that attachments do not contain computer virus code. You are therefore strongly advised to undertake anti virus checks prior to accessing the attachment to this electronic mail. Axios Systems Ltd grants no warranties regarding performance use or quality of any attachment and undertakes no liability for loss or damage howsoever caused. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]