Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For back button support the first (modelChanging) is the important one.

Design rules for writing applications with back button support

In summary, if you want to write an application that fully supports the back button you must know a number of rules:

  • Before you change a model of a component, call modelChanging() on the component, after making the change call modelChanged()
  • Pages are versioned by default but Forms are not. If you want to make a form versioned call form.setVersioned(true) on the form right after all components have been added (not before). This holds at least for wicket version 1.2.2
  • If you are keeping state in your component apart from the component models (e.g. as instance variable or in data providers) make sure that the changes are versioned. You can implement versioning by adding a Change object that can undo the change using Component.addStateChange(Change) as described above.

Component models and versioning

Component models are automatically versioned by creating a copy using Java Serialization (triggered by modelChanging()). Nevertheless, if you construct a model (say CompoundModel) with a model and save the same object as a private instance variable, you may have a problem with versioning. This is because for instance a CompoundModel uses only getters and setters to manipulate its model. As a result, if you apply operations other than getters and setters on your model you have to version it explicitly.

...