


Avoid unwrapping models within the constructor hierarchy, i.e. do not call _IModel.getObject()_ within any constructor. As already mentioned, a page instance can exist for several page requests, so you might store obsolete and redundant information. It is reasonable to unpack Wicket Models at events (user actions), that are methods like _onUpdate()_, _onClick() or _onSubmit()_:

*Listing 10:*

[source,java]
----
new Form<Void>("register") {
    public void onSubmit() {
        // correct, unwrap model in an event call
        Registration reg = registrationModel.getObject()
        userService.register(reg);
    }
}
----

An additional possibility to unwrap models is via overriding methods like _isVisible()_, _isEnabled()_ or _onBeforeRender()_.
