When developing with Apache Wicket, there are times when you won’t be able to use wicket-spring to access your bean implementations. Here is a simple example that you can add to your Wicket Application class to make accessing the context easier
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
protected void init() {
...
ServletContext servletContext = super.getServletContext();
applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
...
}
private ApplicationContext applicationContext;
public Object getBean(String name) {
if (name == null) return null;
return applicationContext.getBean(name);
}