Issue Details (XML | Word | Printable)

Key: DISPL-375
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Reporter: Michael Watts
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DisplayTag

ClassCastException in HeaderCell.addToTotal when totaling column

Created: 13/Jul/06 05:51 PM   Updated: 14/Aug/07 04:31 PM   Resolved: 13/Jul/06 06:14 PM
Return to search
Component/s: Tag Library
Affects Version/s: 1.1
Fix Version/s: 1.1.1

Time Tracking:
Not Specified


 Description  « Hide
I am getting a ClassCastException in org.displaytag.model.HeaderCell.addToTotal when value for cell is the empty string "". This is a problem when totaling a column using the total="true" attribute on ColumnTag.

This method should be changed to avoid this problem. Here is my proposed:

Original:
=====
    private void addToTotal(Object value)
    {
        if (value != null)
        {
            this.total = this.total + ((Number) value).doubleValue();
        }
    }
=====

Proposal:
=====
    private void addToTotal(Object value)
    {
        if (value != null && value instanceof Number)
        {
            this.total = this.total + ((Number) value).doubleValue();
        }
    }
=====

andy pruitt added a comment - 13/Jul/06 06:14 PM
It's already been fixed on head.