Ed Webb wrote:
> Rick Herrick wrote:
>> Ed Webb wrote:
>>
>>> fea jabi wrote:
>>>
>>>> Thanks for your responses. I appreciate that.
>>>>
>>>> I used the JSTL to format the date. Will it work using that? Do I have
>>>> to
>>>> use decorator itself?
>>>>
>>> Use the Decorator instead
>>
>> I was actually going to suggest using JSTL for the date format.  That
>> lets
>> the sort work on the date object directly (instead of the text
>> representation of the date), but doesn't require extra code.  I have an
>> adversion to using decorators.  Also, the JSTL date format is easily
>> localizable and easily changeable in a deployed app, whereas changes to
>> code require redeployment or hot-patching of the app.
>>
>> Why would you recommend using the decorator instead?
>>
>  From what I remember from the original post, using the JSTL did not
> allow the dates to be sorted chronologically, they were being sorted
> alphabetically. If the JSTL can be used to format the date and
> DisplayTag can correctly sort the Date objects then that'd be the easier
> option. I think that's already been tried and found to not work which is
> why I suggested a Decorator. I suspect I encountered a similar problem
> when I began working with DisplayTag but it was so long ago now that
> I've forgotten.

The issue with the sorting would depend on the output of the getter.  If
the getter puts out a Date object, then sorting would sort
chronologically.  If the getter puts out a string containing a formatted
date, then it would sort alphabetically.  Just whatever the default
comparator for the data type is.

You need to treat the tags for the date a bit differently when you're
using JSTL, however.  Instead of something like:

<display:column property="myDate"/>

Instead do something like (assuming table tag declares uid="item"):

<display:column sortProperty="myDate" title="Date">
   <fmt:formatDate value="${item.myDate}" pattern="MM/dd/yyyy"/>
</display:column>

You'll want to play with the pattern and maybe some other attrs on the
<fmt:formatDate> tag.  There are also some neat ways to set up
localization with this in conjunction with the <fmt:setLocale> tag, but I
don't really know how to do it.

-- 
Rick Herrick
[EMAIL PROTECTED]

Proud member of the reality-based community

Never try to discourage thinking for you are sure to succeed.--Bertrand
Russell

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to