I don't know if this is too much of a hack or not, but you can create a
wrapper class for the column. This class would hold the values for both id
and name and implement Comparable and Serializable. Then you would override
the comparable method to just compare the name attribute and the toString
method to generate the HTML <a href.. > code ... also don't forget to
override the equals and hashCode methods also (thanks, Will !).
Then on HoldItem, you would create an instance of the Wrapper and the setId
and setName methods would also set the variables on the Wrapper object. And
your column "property" would be the Wrapper object.
It seems to work ok for me; so, let me know if you have any problems!
> -----Original Message-----
> From: Jay Glanville [SMTP:[EMAIL PROTECTED]
> Sent: Thursday, May 27, 2004 9:14 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [displaytag-user] How can I sort based not on what's in
> the cell?
>
> Thanks for the suggestions Anne. However, neither fit my situation very
> well. Here's why:
>
> For a ColumnDecorator, you get passed only the contents of the cell.
> How is this a problem? Well, the cell maps to a bean's attribute. I
> need the full bean in order to create my URL. For example, I have a
> bean called HoldItem, with at least two attributes:
> public class HoldItem {
> private int id;
> private String name;
> }
> If I use a column decorator, I get passed the name attribute, whereas,
> in order to create the URL, I also need the id of the current bean. In
> other words, the column decorator doesn't give me enough context to
> decorate the column.
>
>
>
> The suggestion to put the decoration into the JSP is also a nice
> suggestion but it falls down for two reasons. The first is that if I
> want the same table on two different pages, I now need to duplicate my
> in-page decoration. If at all possible, avoid duplication. This is why
> the concept of a table decoration is the right idea, its just to bad the
> implementation doesn't cover all the functionality.
>
> The second reason why in-page decoration fails (for me, anyways) is
> because I have a dynamic table: I have one page that is used to present
> many different tables, and thus uses many different table decorations /
> definitions. (This page is used to present the results of a search,
> where the table changes depending on the area the user is searching in.)
> For example, my displaytag usage looks like this:
> <display:table
> .... Table properties removed
> >
> <logic:iterate
> id="currentCol"
> name="SearchFormBean"
> property="tableDesc.columnDescriptions">
> <display:column
> title="${currentCol.titleI18n}"
> property="${currentCol.property}"
> sortable="${currentCol.sortable}"
> decorator="${currentCol.decorator}"
> />
> </logic:iterate>
> </display:table>
> This allows me tremendous amounts of flexibility: to change the table's
> contents and columns, simply change the table definition in the calling
> action.
>
> Therefore, I can't use in-page decoration, as it's specific to only one
> column in one table definition.
>
>
> Is there any other way to do pre-decoration sorting?
>
> JDG
>
> PS: Again, thanks for the suggestions Anne.
>
>
>
> --
> Jay Glanville
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On
> > Behalf Of Liu, Anne I
> > Sent: Tuesday, May 18, 2004 3:19 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: [displaytag-user] How can I sort based not on
> > what's in the cell?
> >
> >
> > You can either use a custom ColumnDecorator (which changes the display
> > post-sort) or you can put the code inside your column tag
> > (example below)
> >
> > <display:table id="row">
> > <display:column>
> > <a href="HoldItem.do?method=edit&id=<c:out
> > value="${row_rowNum}"/>">Comfort Tone</a>
> > </display:column>
> > </display:table>
> >
> > I hope this helps!
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]
> > > Sent: Monday, May 17, 2004 11:09 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [displaytag-user] How can I sort based not
> > on what's in
> > > the cell?
> > >
> > >
> > >
> > >
> > >
> > > > I think I've found the source of my sorting problems. I
> > have a table
> > > > decorator that converts the cell's value into a link. I
> > believe that
> > > > the sorting is being done based on the href text.
> > >
> > > That's exactly the problem I've been having. I'd be really
> > interested in
> > > having
> > > a solution too...
> > >
> > > Thanks,
> > >
> > > - Yagiz -
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by: SourceForge.net Broadband
> > > Sign-up now for SourceForge Broadband and get the fastest
> > > 6.0/768 connection for only $19.95/mo for the first 3 months!
> > > http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
> > > _______________________________________________
> > > displaytag-user mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/displaytag-user
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: SourceForge.net Broadband
> > Sign-up now for SourceForge Broadband and get the fastest
> > 6.0/768 connection for only $19.95/mo for the first 3 months!
> > http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
> > _______________________________________________
> > displaytag-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/displaytag-user
> >
-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
displaytag-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-user