aspose file tools*
The moose likes Spring and the fly likes Proper Usage of the Dependency Injection in MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Proper Usage of the Dependency Injection in MVC" Watch "Proper Usage of the Dependency Injection in MVC" New topic
Author

Proper Usage of the Dependency Injection in MVC

Csabba Csurja
Greenhorn

Joined: Jan 12, 2012
Posts: 12
Hello Guys,

I am curious about your opinion regarding to the proper implementation/usage of DI in Spring MVC:

There are two classes: One Controller which works with a List (for dropdown menu) and there is an another Service class which carries the List elements from DB layer.
How would you inject Service into Contoller in Spring MVC?






My questions:
Is there a way to inject DropDownService.getDropDownItems() elements into DropDownController.dropDownItems List through Dependency Injection in this case? If yes, then how ;-)

Actually, I am looking for the most sophisticated solution, for this reason I am curious about your opinion!

Thanks,
Csaba

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6



To me that is the easiest. I am also under the assumption that you see the typo in your DropDownSerivce class and that that class is defined in a Spring configuration, either with @Service or as a ><bean> in your xml.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Csabba Csurja
Greenhorn

Joined: Jan 12, 2012
Posts: 12
Thanks Mark!

Can I say, that I was not able to see the wood for the trees ? ;-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Proper Usage of the Dependency Injection in MVC