Johan Compagner wrote:
Components (when removed or added) are versioned and models when changed are versioned.
Only we have to know that.  So if you change an internal private model directly
you have to call page.addStateChange(new Change());

and that change object has to be able to rollback your change you are doing now.

Ok, thats very clear. So to complete the design I would have to create a change implementation like this:

class SelectPersonChange extends Change {

    private Set _selections;
    private int _id;  
    private boolean  _selected; // true if it was selected, false if it was unselected.
   
    public SelectPersonChange(Set aSelections, int aId, boolean aSelected) {
        _selections = aSelections;
        _id = aId;
        _selected = aSelected;
    }

    protected void undo() {
        if ( _selected ) {
            _selections.remove(_id);
        }
        else {
            _selections.add(_id);
        }
    }
}

And this would be used by the check box model.

Now one more question. What is the reason that the pages themselves are not versioned? The way that versioning is implemented for model objects is simply cloning them using Java Serialization. So in principle the same approach would have been possible with pages. Oversimplifying it, the 'only thing' to be done would be to reinject the pages and components with any references to transient objects upon deserialization.

I am a bit confused now by the slogan 'transparent back button support' since it now turns out that a lot of work needs to be done in a number of cases to make sure back button support works. In other words, back button support is not transparent at all, especially if I have to implement version management myself. I think the knowledge level required to solve the back button problem for applications transcends the capabilities of average developers and in practice many applications will be written with wicket that don't behave well with the use of the back button. So at best wicket provides support for solving the back button problem.

Right now, if I would have to develop a wicket application with full back button support using inexperienced developers, I would probably have to give design rules such as this:
  • do not store any data as instance variables but retrieve them from the models of the components.
  • Always call modelChanging() before changing a model and modelChanged() after a change.

Cheers
   Erik


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