Our Blog

Let us find tech solutions together

Jul 20

Wicket and Spring

By kinabalu | Comments

 

Wicket makes it very easy to integrate directly with the Spring Framework.

In any Component (Page, Panel, etc) to include a Spring bean you would do:

1
2
    @SpringBean
    private MyBean myBean;

In your application-specific Application class you would do the following:

1
2
3
4
5
6
7
8
9
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

...

   @Override
    protected void init {
        addComponentInstantiationListener(new SpringComponentInjector(this));
        ...
    }

If you’re using Maven for your build management, you would pull in these dependencies assuming wicket 1.3:

1
2
3
4
5
6
7
8
9
10
11
        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-spring</artifactId>
            <version>${wicket.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.wicket</groupId>
            <artifactId>wicket-spring-annot</artifactId>
            <version>${wicket.version}</version>
        </dependency>