Click
  1. Click
  2. CLK-40

Null Decorator values returned in Column renderTableData raise exception

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core
    • Labels:
      None
    • Environment:
      Click-0.15, all enironments

      Description

      I have a row in a Table that represents an object instance (eg User). Once of the object attributes (role) is another object. If the User does not have a Role, I get an exception - 'IllegalArgumentException on HTMLStringBuffer - null value parameter' (line 93 in HTMLStringBuffer)

      I think the problem is around line 393 in Column.java. A test for a null value before doing a buffer.append() would fix this

      I'm subclassing Column right now to override the renderTableData method, which seems to work. The pertinent lines of code are:

      (replace line 393 with)
      if (columnValue != null)

      { buffer.append(columnValue); }

      Or should HTMLStringBuffer be more forgiving? Or both?

        Activity

        Hide
        Geoff Hopson added a comment -

        In Click 0.17 this bug has reappeared. The fix is as detailed in the original bug report.

        Show
        Geoff Hopson added a comment - In Click 0.17 this bug has reappeared. The fix is as detailed in the original bug report.
        Hide
        Geoff Hopson added a comment -

        I tell a lie - the problem is to do with the Decorator, render and null results.

        Offending line 380:
        buffer.append(getDecorator().render(row, context));

        The result of my render operation is null, which is causing the HTMLStringBuffer to barf.

        CAn HTMLStringBuffer be amended to absorb null parameters?

        Show
        Geoff Hopson added a comment - I tell a lie - the problem is to do with the Decorator, render and null results. Offending line 380: buffer.append(getDecorator().render(row, context)); The result of my render operation is null, which is causing the HTMLStringBuffer to barf. CAn HTMLStringBuffer be amended to absorb null parameters?
        Hide
        Malcolm Edgar added a comment -

        Hi Geoff,

        I this case I think the returned decorator value should not be rendered, e.g.

        if (getDecorator() != null) {
        Object value = getDecorator().render(row, column);
        if (value != null)

        { buffer.append(value); }

        } else {
        ..

        I prefer that HTMLStringBuffer to raise an exception as it highlights logic errors.

        regards Malcolm

        Show
        Malcolm Edgar added a comment - Hi Geoff, I this case I think the returned decorator value should not be rendered, e.g. if (getDecorator() != null) { Object value = getDecorator().render(row, column); if (value != null) { buffer.append(value); } } else { .. I prefer that HTMLStringBuffer to raise an exception as it highlights logic errors. regards Malcolm
        Hide
        Geoff Hopson added a comment -

        That's fine by me - that's how I fixed my issue locally.

        I think a line in the documentation would be good. It might already be there, not checked.

        Show
        Geoff Hopson added a comment - That's fine by me - that's how I fixed my issue locally. I think a line in the documentation would be good. It might already be there, not checked.
        Hide
        Malcolm Edgar added a comment -

        fix checked into CVS

        Show
        Malcolm Edgar added a comment - fix checked into CVS

          People

          • Assignee:
            Malcolm Edgar
            Reporter:
            Geoff Hopson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development