On 12/13/05, Laurent PETIT <[EMAIL PROTECTED]> wrote:
Hello Igor,

On 12/13/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> I did not put this strategy [ReuseIfModelObjectsEqualStrategy] in extensions on purpose.
> The reason being is that this can really get you in trouble when dealing with detachable models.
> Imagine changing a page and having all the model's from last page load as
> well as all the models on this page. The idea behind ifmodelequals was that
> when you compare detachable models you can just compare the database ids of
> objects they point to instead of loading the objects from the db.

Well, maybe it's too late, but I don't really understand your example.
Could you please give a concrete "scenario" to help me understand ?

keep in mind dataview was primarily designed to be used with database data.
imagine you are using the dataview to display a list of users form the database. each user is represented by a detachable model. you are on page 1. now you click page 2. if you are doing equality on the model object and not the model when the strategy runs it will call model.getObject().equals() on all your old items (from page1) and try to compare to the items on the new page (page2). so that means model.getObject() is called on all models from page 1 which causes them to load from the database. you dont want that.

but in your case it is ok because you are not loading things from the database. 

as far as the models go, maybe what you can do is make a "detachable" model that instead of the identity keeps the index of the list. so when you call getobject() on it it will retrieve that object from the list by its index.

-Igor

Reply via email to