Bugs item #928272, was opened at 2004-04-02 16:21 Message generated for change (Comment added) made by rebus76 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=536613&aid=928272&group_id=73068
Category: main tag library Group: v 1.0-b3 Status: Closed Resolution: Works For Me Priority: 5 Submitted By: Tatiana Akamine (tatak) Assigned to: fabrizio giustina (fgiust) Summary: Date and Long columns sorting Initial Comment: I've got Long and Date columns (that implement the Comparable interface) but it seems that they are not being sorted as Longs and Dates but as Strings. For example, a column with values 10, 90, 100 is sorted like 10, 100, 90. ---------------------------------------------------------------------- Comment By: alex veneziano (rebus76) Date: 2004-05-13 17:04 Message: Logged In: YES user_id=1041209 Hi, I have modified Cell.java for sort numeric data when is not used the "property" attribute. This is the source: import org.apache.commons.lang.builder.ToStringBuilder; import java.lang.Double; import java.lang.NumberFormatException; /** * <p>Represents a table cell.</p> * <p>A cell is used only when the content is placed as content of the column tag and need to be evaluated during * iteration. If the content is set using the <code>value</code> attribute in the column tag no cell is created and * EMPTY_CELL is used as placeholder.</p> * @author fgiust * @ Update by Alessandro Veneziano * @version $Revision$ ($Author$) */ public class Cell implements Comparable { /** * empty cell object. Use as placeholder for empty cell to avoid useless object creation. */ public static final Cell EMPTY_CELL = new Cell(); /** * content of the cell. */ private Object staticValue; /** * Creates a new empty cell. This should never be done, use EMPTY_CELL instead. */ private Cell() { } /** * Creates a cell with a static value. * @param value Object value of the Cell object */ public Cell(Object value) { this.staticValue = value; } /** * get the static value for the cell. * @return the Object value of this.staticValue. */ public Object getStaticValue() { return this.staticValue; } /** * set the static value of the cell. * @param value - the new value for this.staticValue */ public void setStaticValue(Object value) { this.staticValue = value; } /** * Compare the Cell value to another Cell. * @param obj Object to compare this cell to * @return int * @see java.lang.Comparable#compareTo(Object) */ public int compareTo(Object obj) { if (this.staticValue == null) { return -1; } try { Double NumericValue1,NumericValue2; NumericValue1 = new Double(this.staticValue.toString ()); if (obj instanceof Cell) { NumericValue2 = new Double(((Cell) obj).getStaticValue().toString()); } else { NumericValue2 = new Double(obj.toString()); } return NumericValue1.compareTo(NumericValue2); } catch(NumberFormatException e) { if (obj instanceof Cell) { return ((Comparable) this.staticValue).compareTo (((Cell) obj).getStaticValue()); } else { return ((Comparable) this.staticValue).compareTo (obj); } } } /** * Simple toString wich output the static value. * @return String represantation of the cell */ public String toString() { return new ToStringBuilder(this).append("staticValue", this.staticValue).toString(); } } Sorry for my English. Alex :-) ---------------------------------------------------------------------- Comment By: fabrizio giustina (fgiust) Date: 2004-04-25 16:51 Message: Logged In: YES user_id=798060 closing the bug since I got no reply. I'm assuming the user was not using the "property" attribute. ---------------------------------------------------------------------- Comment By: fabrizio giustina (fgiust) Date: 2004-04-06 23:37 Message: Logged In: YES user_id=798060 are you using the "property" column attribute or column tag body? Sorting is supposed to work only using property, values are always sorted as String in body. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=536613&aid=928272&group_id=73068 ------------------------------------------------------- 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-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/displaytag-devel