API / Apache Wicket Interview questions
How does Wicket integrate with Spring for dependency injection?
Wicket doesn't include a dependency injection container of its own; instead the wicket-spring module bridges Wicket's component construction to an existing Spring ApplicationContext, so Spring-managed beans (services, repositories) can be injected directly into Page and Panel classes.
The integration is wired up once, in the Application subclass's init() method, by registering a SpringComponentInjector. After that, any component can simply annotate a field with @SpringBean (Wicket's own annotation, functionally similar to @Autowired), and the injector fills it in automatically as part of each component's construction — no manual applicationContext.getBean() lookups scattered through page code.
Because Wicket components (unlike Spring beans) are frequently constructed per-request or per-user rather than as long-lived singletons, this pattern specifically solves the mismatch between Spring's typical singleton-bean lifecycle and Wicket's much shorter-lived component instances, letting the two coexist without one framework fighting the other's object lifecycle assumptions.
More Related questions...