Wicket and Spring

by kinabalu on July 20, 2009

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:

    @SpringBean 
    private MyBean myBean;

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

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:

        <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>

Similar Posts:

Share this:
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Slashdot
  • Technorati

{ 5 comments… read them below or add one }

DavidNo Gravatar August 4, 2009 at 6:03 pm

Builds, tests and runs but when I click on the page link that uses the bean defined I get:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘masterDao’ is defined

kinabaluNo Gravatar August 4, 2009 at 7:33 pm

David,

Can you provide your applicationContext.xml, web.xml, and any related code that might make sense here. The example you’ve commented on does not include a masterDao, so we’d need some context to help out.

Cheers!

Frank BNo Gravatar May 9, 2010 at 11:12 am

How about some guide for what to put inside the web.xml and applicationContext.xml?

Zlatan KadragićNo Gravatar August 28, 2010 at 2:28 am

Just to add my Maven experience using wicket 1.4..10 and Spring 3.0.4

pom.xml file should look like this:

org.springframework
spring-core
${spring.version}

org.springframework
spring-web
${spring.version}

org.springframework
spring-jdbc
${spring.version}

and so on.

Zlatan KadragićNo Gravatar August 28, 2010 at 2:33 am

And this:

org.apache.wicket
wicket-spring
${wicket.version}

wicket-spring-annot is not needed

Leave a Comment

Previous post:

Next post: