Hello.
Of course, objects updated in the database shouldn't be equal to those
previously displayed in the table (they aren't equal). If you don't comply
to this you'll have problems not only with inmehtod grid.
The equals method of my beans always include at least this:
++++
if (this.id != other.id && (this.id == null || !this.id.equals(
other.id))) {
return false;
}
if (this.version!= other.version&& (this.version== null ||
!this.version.
equals(other.version))) {
return false;
}
+++
The above may also be the problem when dealing with the selection, because
an object previously selected that has been updated in the database, won't
be selected again (it won't equals the previous version). That is why you
should implement your own selection methods in the DataGrid if you're
dealing with objects from a database.
Regards
On Wed, Apr 20, 2011 at 15:42, Chris Colman <[email protected]>wrote:
> I tried this exact thing today and had the same results.. no update
>
> grid.markAllItemsDirty();
> grid.update();
>
> I have a feeling that the equals method has to return false when objects
> are updated to force a redisplay. For this reason I'm guessing that the
> equality should not be solely based on the object's database id because that
> doesn't change when the object is updated.
>
> Perhaps we could include the object's version number in the equality test
> as well, which will change when the object is updated (version is
> automatically managed by our ORM but probably same across most ORMs).
>
> In our case we use JDO so I'm guessing if we add an extra comparison to the
> equals method we might get the update working as expected eg.,
>
>
> boolean
> equals(Object obj)
> {
> ....
>
> if ( !JDOHelper.getVersion(this).equals(JDOHelper.getVersion(obj) )
> return false;
>
> ....
> }
>
>
> Hmmm, I'll try that first thing tomorrow morning when I hit the office.
>
>