DisplayTag

ClassCastException in HeaderCell.addToTotal when totaling column

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.1
  • Fix Version/s: 1.1.1
  • Component/s: Tag Library
  • Labels:
    None

Description

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();
        }
    }
=====

Activity

Hide
andy pruitt added a comment -
It's already been fixed on head.
Show
andy pruitt added a comment - It's already been fixed on head.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: