I personally think it is easer to override the init method of your application:
protected void init() {
super.init();
addComponentInstantiationListener(new SpringComponentInjector(this));
...
}
and use the @SpringBean where you want to use your DAO.
@SpringBean
ContactDao contactDao
/Mats
On 1/15/07, Peter Thomas <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I was thinking that more option can be added to the official wicket-spring
> integration documentation. Something like this:
>
> 1) normal wicket servlet config in web.xml, with applicationClassName
> init-param
>
> 2) Application class uses Spring API to get hold of dependency like this:
>
> class MyApplication extends WebApplication {
> private ContactDao dao;
> public ContactDao getContactDao() { return dao; }
>
> public void init() {
> ServletContext sc =
> getWicketServlet().getServletContext();
> dao = (ContactDao)
> WebApplicationContextUtils.getWebApplicationContext(sc).getBean("contactDao");
> }
> }
>
> 3) Have all pages / components extend BasePage that has a getContactDao()
> method - exactly like the first option in the wicket-spring wiki
> documentation here:
> http://www.wicket-wiki.org.uk/wiki/index.php/Spring
>
> I understand the risk of running into the serialization problem and also
> that this may be considered not-so-elegant because of using the Spring API
> directly without any dependency injection. But I want to mention my
> experience, I spent a lot of time going through the existing documentation
> agonizing over which option to choose. Trying to understand all the
> options, lazy proxies etc was a little daunting for a spring fan like me.
>
> In my case I just have one clean dependency and finally it was so easy to do
> it as suggested above. I also don't need the wicket-spring jar at all. Are
> there any other compelling reasons for using the wicket-spring lib? Is the
> suggested approach fine for small projects who want to hook into Spring
> quickly?
>
> Another thing - I initially tried to use wicket-spring-annot and Maven 2
> complained with this error:
>
> ========
>
> [INFO] Failed to resolve artifact.
>
> GroupId: wicket
> ArtifactId: wicket-parent
> Version: 1.2-SNAPSHOT
>
> Reason: Unable to download the artifact from any repository
>
> wicket:wicket-parent:pom:1.2-SNAPSHOT
>
> from the specified remote repositories:
> central ( http://repo1.maven.org/maven2)
>
> =========
>
> I think the reason is because the wicket-spring-annot-1.2.4.pom incorrectly
> refers to 1.2-SNAPSHOT version for wicket-parent. The url of the offending
> file in the maven repository is this:
>
> http://repo1.maven.org/maven2/wicket/wicket-spring-annot/1.2.4/wicket-spring-annot-1.2.4.pom
>
> Let me know if I need to log an issue or something.
>
> Thanks,
>
> Peter.
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user