http://displaytag.homeip.net/displaytag-examples-1.1/example-format.jsp
You can use any valid
java.text.MessageFormat
pattern in the format
attribute. Sorting
will be based on the original object, not on the formatted String.
Note that errors due to an invalid pattern/object combination (for example trying to format a String like a number) will not be rethrown. Instead, an error log will be written and the original unformatted object displayed.
You can also use a format
pattern along with column decorators (the pattern will be applied after the
decoration).
<display:table name="test">
<display:column property="id" title="ID" />
<display:column property="email" format="email is {0}" />
<display:column property="date" format="{0,date,dd-MM-yyyy}" sortable="true"/>
<display:column property="money" format="{0,number,0,000.00} $" sortable="true"/>
</display:table>
Ricardo.
On 10/26/06, fea jabi <[EMAIL PROTECTED]> wrote:
thanks for your reply. But can you be more specific in what needs to be
changed. maybe an example will help.
Thanks.
>From: "Paul Cooper" <[EMAIL PROTECTED]>
>Reply-To: displaytag-user@lists.sourceforge.net
>To: <displaytag-user@lists.sourceforge.net>
>Subject: Re: [displaytag-user] sort not working for Date
>Date: Wed, 25 Oct 2006 19:25:46 -0400
>
>Wow, lots of basic ASCII sorting questions.
>
>Your sort below is a descending ASCII sort. So is the second. If you use
>the actual date values to sort, but display the text versions, it will
>work as you expect.
>
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto: [EMAIL PROTECTED]] On Behalf Of fea
>jabi
>Sent: Wednesday, October 25, 2006 6:51 PM
>To: displaytag-user@lists.sourceforge.net
>Subject: [displaytag-user] sort not working for Date
>
>have an obj Customer
>
>Customer has attributes
>name - String
>createDate - Date
>
>
>In my struts prepare action I am creating the list of Customer objects
>
>below I am showing only createDate values.
>
>DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
>
>custObj1.setCreateDate(dateFormat.parse("7-1-2005"));
>custObj2.setCreateDate(dateFormat.parse("10-10-2005"));
>custObj3.setCreateDate(dateFormat.parse("6-10-2004"));
>custObj4.setCreateDate(dateFormat.parse("1-10-2005"));
>custObj5.setCreateDate(dateFormat.parse("10-10-2005"));
>custObj6.setCreateDate(dateFormat.parse("07-1-2005"));
>custObj7.setCreateDate(dateFormat.parse("10-10-2005"));
> custObj8.setCreateDate(dateFormat.parse("6-10-2004"));
>custObj9.setCreateDate(dateFormat.parse("1-10-2005"));
>custObj10.setCreateDate(dateFormat.parse("10-10-2005"));
>
>created list of this custObj 's
>
>in jsp
><display:table name="sessionScope.Form1.custList" id="custRow"
>requestURI="PrepareAction.do" defaultsort="2" defaultorder="descending"
>
>pagesize="6">
>.......
>......
><!-- Create Date -->
><display:column titleKey="lbl.crdate" sortable="true" >
> <c:if test="${ custRow.createDate != null}" >
> <fmt:formatDate value="${custRow.createDate}"
>pattern="MM-dd-yyyy" var="crtDate"/>
> <c:out value="${crtDate}"/>
> <!--c:out value="${custRow.createDate}"/-->
> </c:if>
></display:column>
>..........
>............
></display:table>
>
>Using this I am getting data for createDate as using formatting of JSTL
>10-10-2005
>10-10-2005
>10-10-2005
>10-10-2005
>07-01-2005
>07-01-2005
>06-10-2004
>06-10-2004
>01-10-2005
>01-10-2005
>
>without using formatting getting values as
>Thu Jun 10 00:00:00 EDT 2004
>Thu Jun 10 00:00:00 EDT 2004
>Mon Oct 10 00:00:00 EDT 2005
>Mon Oct 10 00:00:00 EDT 2005
>Mon Oct 10 00:00:00 EDT 2005
>Mon Oct 10 00:00:00 EDT 2005
>Mon Jan 10 00:00:00 EST 2005
>Mon Jan 10 00:00:00 EST 2005
>Fri Jul 01 00:00:00 EDT 2005
>Fri Jul 01 00:00:00 EDT 2005
>
>either way sort seams to be wrong.
>
>What am I missing here? is there something else that I need to do to
>sort
>this createDate column?
>
>Thanks.
>
>_________________________________________________________________
>Stay in touch with old friends and meet new ones with Windows Live
>Spaces
>http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href="">
>/spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mk
>t=en-us
>
>
>------------------------------------------------------------------------
>-
>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
>
>
>
>-------------------------------------------------------------------------
>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
_________________________________________________________________
Try Search Survival Kits: Fix up your home and better handle your cash with
Live Search!
http://imagine-windowslive.com/search/kits/default.aspx?kit=improve&locale=en-US&source=hmtagline
-------------------------------------------------------------------------
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
------------------------------------------------------------------------- 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