...
Code Block |
---|
class MyApplication extends WebApplication { public void init() { super.init(); getComponentInstantiationListeners().add(new SpringComponentInjector(this)); } } |
Here the page (or indeed anything derived from a Wicket {{ Wiki Markup Component
}}) will have its dependencies injected when created. _\[Constructor/superclass chaining down to the Component(final String id, final IModel model) constructor, where there's a call to getApplication().notifyComponentInstantiationListeners(this);\]_
When doing this it is important to remember not to initialize dependencies, to null or any other value, e.g.private ContactDao dao=null;
. Don't do this because the injector will run before the subclass initializes its fields, and so the dao=null
will override the created proxy with null.
...