Direct Approach
This approach uses static lookups to retrieve needed spring beans.
Pros:
|
Cons:
- Objects are tightly coupled to the WebApplication subclass
|
Interesting classes:
- ExampleApplication - serves as a link between wicket and spring ApplicationContext
- DirectPage - sets up the data table below
- DirectDataProvider
- DirectModel
Below is the code from DirectModel which is a detachable contact model. Notice the static lookup used to retrieve the spring bean needed to reload the Contact from the database.
DirectModel.java
public class DirectModel extends ContactDetachableModel {
public DirectModel(Contact contact) {
super(contact);
}
protected ContactDao getContactDao() {
return ((ExampleApplication) Application.get()).getContactDao();
}
}