Re: CellTable - TextColumn.getValue (null) - another strange problem

2013-06-26 Thread Magnus


Am Mittwoch, 26. Juni 2013 10:10:17 UTC+2 schrieb Thomas Broyer:
>
> Looks like 
> https://code.google.com/p/google-web-toolkit/issues/detail?id=7030


Thank you!
 

> This can cause a call to the Column's getValue(T object) with a null 
> value, when the HasDataPresenter.setVisibleRange is called and null values 
> are inserted at the beginning of the (pending) rowData collection and the 
> focus in on one of the cells within those rows. 


"and null values are inserted at the beginning of the (pending) rowData 
collection":

I am not sure how to interpret this: The only time when I (my code) insert 
values into the list is within the onRangeChange method. Then, I make an 
aynchroneous server call and when it returns, I insert the data like this:

--
--
Pager pgr = getPager (); Range r = pgr.getDisplay().getVisibleRange(); int 
start = r.getStart(); pvrovider.updateRowData (start,lst); // lst contains 
the data 
--
--

I am really sure that there are no null values within this data...

The issue you pointed to was posted in 2011. Is it still unsolved in GWT?

Magnus




-- 
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+unsubscr...@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.




Re: CellTable - TextColumn.getValue (null) - another strange problem

2013-06-26 Thread Thomas Broyer
Looks like 
https://code.google.com/p/google-web-toolkit/issues/detail?id=7030

On Wednesday, June 26, 2013 8:23:13 AM UTC+2, Magnus wrote:
>
> Hello,
>
> 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 col_Start = new TextColumn()
>   {
>@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
> {
>  public CellListCarrier   crr = null;
>  public CellTable  tbl = null;
>  public AsyncDataProvider  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 = new CellTable ();
>   setTable (t);
>  }
>  
>  public void createProvider ()
>  {
>   pvd = new AsyncDataProvider()
>   {
>@Override
>protected void onRangeChanged(HasData 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 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 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> s = pvd.getDataDisplays();
>   
>   if (s == null)
>return (false);
>   
>   if (s.isEmpty())
>return (false);
>   
>   ret

CellTable - TextColumn.getValue (null) - another strange problem

2013-06-25 Thread Magnus
Hello,

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 col_Start = new TextColumn()
  {
   @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
{
 public CellListCarrier   crr = null;
 public CellTable  tbl = null;
 public AsyncDataProvider  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 = new CellTable ();
  setTable (t);
 }
 
 public void createProvider ()
 {
  pvd = new AsyncDataProvider()
  {
   @Override
   protected void onRangeChanged(HasData 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 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 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> 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+unsubscr...@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.