I just looked a bit at the code for ModelChange.java in wicket 2. I see the problem now. The CompoundPropertyModel is being cloned so if there is another model referring to that model, it will always refer to the wrong version of the model in case an old version of the page is requested.

A solution would be to introduce one level of indirection. Instead of directly referring to a property model in a child model, the model should refer to the model using a unique id of the model (generated by wicket internally).  Wicket should then maintain a mapping of model id to model.

Then, when an old page version is requested, old versions of models are simply put in this map, and references will continue to work because of the indirection through the model id which is constant.

Reference lookups can be encapsulated using something like this:

class ModelReference<T extends IModel {
    private String _id;

    public ModelReference(T aModel) {
        _id = ModelRegistry.getUniqueModelId(aModel); // register the model if needed and generate a unique id.
    }

    T get() {
          ... lookup the model through its id....
          return ModelRegistry.getModel(_id);
    }
}

Of course, there are still problems here, like when to determine that a model is no longer in use and removing it
from the administration. Perhaps we can tie the lifetime of an id to that of the page instance so that when the page is evicted the ids may be reused. In other words, the Page object would provide a getUniqueModelId() method.

Cheers
  Erik


On 9/17/06, Erik Brakkee <[EMAIL PROTECTED]> wrote:
On 9/17/06, Johan Compagner <[EMAIL PROTECTED]> wrote:
i agree with igor. What does this really gain?
How will versioning and then the undo to that version work???

Child components will not do versioning. Only the top-level parent will. The child components simply delegate to their parent.

Or is the problem that wicket will also create a copy of the Child model object? I was assuming that only the actual model object (Person) would be cloned on modelChanging() but not any of the models around it.

johan




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to