PDA

View Full Version : [FIXED] [gxt 1.1] BaseModel map equals() doesn't work anymore



AlexPdro
27 Aug 2008, 9:24 AM
- BaseModel map equals() method doesn't work anymore
- GXT 1.1 alpha1 & 2
- Host mode & web mode
- Windows XP

Sample code :


import com.extjs.gxt.ui.client.data.BaseModel;


public class TestBug extends BaseModel {


public TestBug(String name, Double dbl) {
this.set("name", name);
this.set("value", dbl);
}

/**
* @param args
*/
public static void main(String[] args) {
TestBug m1 = new TestBug("alfredo shsfhsf",new Double(23));
TestBug m2 = new TestBug("alfredo shsfhsf",new Double(23));
System.out.println(m1.equals(m2));
}

@Override
public boolean equals(Object object) {
if (object==null) return false;

if (!(object instanceof TestBug)) return false;

TestBug ref = (TestBug) object;

return this.map.equals(ref.map);

}

}
With gxt 1.0 this code display : true but with 1.1 it displays false.

(I think but I'm not sure that a side effect of that is that some methods of the API doesn't work anymore, I have had some troubles selecting Model from Data widget and removing them. But I'm not yet sure it was because of this because I have noticed that with grids so I can't compare with gxt 1.0. )

darrellmeyer
28 Aug 2008, 7:52 AM
I am not sure how this worked before as equals was never overridden. Nonetheless, I have changed BaseModelData to override equals and hashCode and delegate the calls to the internal map. So your code will work as expected. I have also changed the BeanModel generator to override the same methods and delegate to the wrapped bean. Changes are in SVN.

AlexPdro
28 Aug 2008, 8:49 AM
Great!

Thanks Darell