First, you can still use BeanAction with Spring DAO. The most simple solution to set your static variable is to get it from Spring. First get the SpringContext and do the following. private static final TheService instance = springContext.getBean("theService"); The way you can get SpringContext is relaitve on how you initialize it. This is a code sample of how you can access it if you use org.springframework.web.context.ContextLoaderListener. /** * Listen for Spring initialization. * * @author poitrac */ public class SpringInit implements ServletContextListener { /** * Spring's WebApplicationContext. */ private static WebApplicationContext springContext; public SpringInit() { super(); } /* (non-Javadoc) * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.Se rvletContextEvent) */ public void contextInitialized(ServletContextEvent event) { springContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletCont ext()); } /* (non-Javadoc) * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.Serv letContextEvent) */ public void contextDestroyed(ServletContextEvent event) { } /** * Returns Spring's WebApplicationContext. * @return Spring's WebApplicationContext. */ public static ApplicationContext getApplicationContext() { return springContext; } } Christian
________________________________ From: Meindert [mailto:[EMAIL PROTECTED] Sent: Tuesday, 10 April 2007 12:30 To: user-java@ibatis.apache.org Subject: RE: iBATIS, Spring, and transactions... I'm busy converting and went to the site http://www.learntechnology.net/content/ibatis/spring_ibatis.jsp What is quite a clear explanation :-) I'm converting a project that is based on the jpetstore, what is using org.apache.struts.beanaction.BeanAction in my struts-config.xml The above mentioned site has got a different approach. My question is; a) can I still use org.apache.struts.beanaction.BeanAction? I only want to change the DAO to Spring DAO because IBATIS DAO is depreciated and if so b) The BeanAction class is using private static final TheService theService = TheService.getInstance(); to connect with the service object, what created itself static; private static final TheService instance = new TheService(); How do I get a instance from the spring created service object? My service object get's created by spring using the following config in spring.xml; <bean id=" theService " class="com.service.TheService "> <constructor-arg index="0" ref="theDao"/> </bean> And code; public TheService (TheDao theDao){ this.theDao = theDao; } Kind Regards Meindert -----Original Message----- From: Poitras Christian [mailto:[EMAIL PROTECTED] Sent: 10 April 2007 04:25 PM To: user-java@ibatis.apache.org; [EMAIL PROTECTED] Subject: RE: iBATIS, Spring, and transactions... That would be a great idea! It's always welcome to see some code to show each steps. My app is already to big to use it direclty as an example... Christian I'll check if I can provide you with my smaller app (contains only 2 actions, but it does not have any transaction). I'll just add the insert/updates I used at first to fill database. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Larry Meadors Sent: Tuesday, 10 April 2007 10:16 To: user-java@ibatis.apache.org Subject: Re: iBATIS, Spring, and transactions... That would be AWESOME, if you want, I can help with proofing, etc. Maybe someone else would be willing to provide a *simple* iBATIS DAO sample application that we could convert and then document the process. Larry On 4/10/07, Poitras Christian <[EMAIL PROTECTED]> wrote: > I have to say that it would be really nice to have an "how to" for > passing from iBATIS DAO to Spring DAO... > I made a french document about that question. I could transalte it to > english in the next weeks and put it on the wiki...