after setting an UncaughtExceptionHandler with GWT.setUncaughtExceptionHandler() for the first time, I see a new NullPointerException that I did not see before and which did not cause any visible problems.
The exception occurrs, because the getValue methods of the table's columns are called with a null value, e. g.:
--------------------------------------------------------------------------------
TextColumn<Game> col_Start = new TextColumn<Game>()
{
@Override
public String getValue(Game obj)
{
return (obj.str_Start); // exception, obj is null!
}
};
--------------------------------------------------------------------------------
As said above, there seem to be no consequences. The table's contents seem to be ok. Also, when I check for null values and return "???" instead, the "???" will not appear in the table.
Nevertheless, I do not want to ignore it. Since the getValue methods are called by the GWT framework, I believe that there must be a problem with my own code (rather than a bug in GWT).
It onlly happens, when I navigate from the second page back to the first one, so I assume a problem within the onRangeChange callback method.
However, I have outsourced most of the CellTable handling into a seperate class CellListController (see below). So if there was a problem with my code, it would most likely be located there.
But I really don't know where to start, because I cannot imagine any reason why the framework should call my methods with null values?
Any ideas?
Thank you
Magnus
--------------------------------------------------------------------------------
public class CellListController<T>
{
public CellListCarrier crr = null;
public CellTable<T> tbl = null;
public AsyncDataProvider<T> pvd = null;
public Pager pgr = null;
// Construction
public CellListController ()
{
super ();
}
public CellListController (CellListCarrier crr)
{
setCarrier (crr);
}
// Component Creation
public void createAll (Pager pgr,int pageSize)
{
createTable();
setPageSize (pageSize);
createProvider();
setPager(pgr);
}
public void createTable ()
{
CellTable<T> t = new CellTable<T> ();
setTable (t);
}
public void createProvider ()
{
pvd = new AsyncDataProvider<T>()
{
@Override
protected void onRangeChanged(HasData<T> display)
{
Range r = display.getVisibleRange();
int start = r.getStart() + 1;
int end = start + r.getLength() - 1;
onRangeChange (start,end);
}
};
}
// Settings
public void setCarrier (CellListCarrier crr)
{
this.crr = crr;
}
public void setTable (CellTable<T> tbl)
{
this.tbl = tbl;
tbl.setPageStart (0);
}
public void setPager (Pager pgr)
{
this.pgr = pgr;
pgr.setDisplay(tbl);
pgr.setRangeLimited(true);
}
public void setPageSize (int pageSize)
{
tbl.setPageSize (pageSize);
}
public int getStart ()
{
Range r = pgr.getDisplay().getVisibleRange();
int start = r.getStart();
return (start);
}
// Data
public void load ()
{
pvd.addDataDisplay(tbl);
}
public void reload ()
{
Range r = tbl.getVisibleRange();
reload (r);
}
public void reload (Range r)
{
tbl.setVisibleRangeAndClearData (r,true);
if (!isLoaded ())
load ();
}
public void reloadLast ()
{
int n = tbl.getRowCount();
Range r = getLastRange (n);
reload (r);
}
public void reloadFirst ()
{
int p = tbl.getPageSize();
Range r = new Range (0,p);
reload (r);
}
public Range getLastRange (int cnt)
{
int p = tbl.getPageSize();
int s = cnt - p;
if (s < 0)
s = 0;
Range r = new Range (s,p);
return (r);
}
public void scheduleReload ()
{
Scheduler.get().scheduleDeferred
(
new ScheduledCommand()
{
@Override
public void execute()
{
reloadFirst ();
}
}
);
}
// Callback Methods
public void onRangeChange (int i0,int i1)
{
awi.log("CellListController.onRangeChange(" + i0 + "," + i1 + ")");
crr.loadRecordList (i0,i1);
crr.loadRecordCount ();
}
public void updateRowData (List<T> lst)
{
if (lst == null)
return;
int start = getStart();
pvd.updateRowData (start,lst);
}
public void updateRowCount (int cnt)
{
pvd.updateRowCount (cnt,true);
}
private boolean isLoaded ()
{
Set<HasData<T>> s = pvd.getDataDisplays();
if (s == null)
return (false);
if (s.isEmpty())
return (false);
return (true);
}
}
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment