• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getWebApplicationContext() w/ Struts

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm starting to integrate Spring into one of my Struts applications. I'm using the Spring/Struts Plugin and used ActionSupport to extend my Struts action class. I wire the Service Bean in the application context xml file. From the struts action class i use the getWebApplicaitonContext() to get the bean. My problem is that in the Service Bean I need to get a DAO bean. Right now I'm just creating a new ApplicationContext to get the DAO bean. Is there a better way to do this then have to create a new ApplicaitonContext each time?

I just started with Spring, so be nice!

Thanks,
Alan
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you'll want to do is wire up the DAO and Service so that your DAO is injected into the Service via a setter method. A very simplistic example might be:



And your service class might look like:

reply
    Bookmark Topic Watch Topic
  • New Topic