gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.51k stars 372 forks source link

Column.getValue(T object) called with null value when totalItems % pagesize != 0 using AsyncDataProvider #7614

Open dankurka opened 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 7617

Found in GWT Release (e.g. 2.4.0, 2.5.0 RC):
2.5.0 RC (works as expected in 2.4)

Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7):
Linux (Ubuntu 12.04), FF14

Detailed description (please be as specific as possible):
Null value is passed to Column.getValue(T object) when using celltable/datagrid, when
using AsyncDataProvider and when the total results is not a multiple of the page size.

Example:
Have page size be 5.
Have a total of 36 results.
Click search to get the first "1-5 of 36"
page to the end, (do not use the skip to end)
  - It will show "32-36 of 36" in the pager
Page back to the beginning. (do not use the skip to the beginning)
  - Right before the last time clicking page back, you will see "2-6 of 36"
  - When you click back after seeing this, right after handling AsyncDataProvider.onRangeChanged(HasData<Patient>
display), and before the server returns results 1-5, Null is passed to the columns.
  - the actual functionality is not affected though, as the server returns with the
results, updateRowCount/updateRowData are called and the view is correct.

In GWT 2.4, The AbstractCellTable.renderRowValues has a null check before calling getValue,
where as in 2.5rc, renderRowValues is deprecated and the other calling methods do not
do null checks.  Though I don't know why it would ever try calling getValue with null
values at this point.

Shortest code snippet which demonstrates issue (please indicate where
actual result differs from expected result):

Column<MyObject, String> c = new Column<MyObject, String>(new TextCell()) {
  @Override
  public String getValue(MyObject object) {
      //object is null in the condition described above  
      return object.getFirstName();
  }
};

Workaround if you have one:
check if value is null before proceeding in all the Column.getValue(T object) implementations.

Reported by keith.buel on 2012-08-23 03:38:58

dankurka commented 9 years ago
See also issue 7029.
I'm tempted to mark this issue as a duplicate but you're saying it wasn't an issue
in GWT 2.4.

Reported by t.broyer on 2012-08-25 01:58:24

dankurka commented 9 years ago
A little bit better workaround would be to overload render() method in Column class
with check for the null value: 

@Override
public void render(Context context, MyObject object, SafeHtmlBuilder sb) {
    if(object != null) {
        super.render( context, object, sb );
    }
}

Reported by skatsman on 2013-01-17 18:00:54

dankurka commented 9 years ago
I have the same problem on 2.5.1.

Reported by asim@linxa.com on 2013-03-15 18:17:37

dankurka commented 9 years ago
I can report the same issue.

Reported by michael.anstis on 2014-01-31 10:00:25