aspose file tools*
The moose likes Struts and the fly likes struts and spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts and spring" Watch "struts and spring" New topic
Author

struts and spring

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
can anyone provide an example why using struts with spring is a good idea?

I was requested to make this type of integration and I'm not sure I fully understand what spring can add to struts?

thanks for any pointer.
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
Inversion of control. Bean Injection. In short because IMHO Spring is the best thing since sliced bread.
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Inversion of control. (Ioc) is a design pattern.

>can anyone provide an example why using struts with spring is a good idea?
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
You asked why it was a good idea. Inversion of control is why it is a good idea. It makes your view less closely tied to your application. Makes it much easier to swap out.

And no, IoC isn't really a design pattern, but more a general principle or set of design patterns which include:

Separation of Concerns
Interface Driven Design
Dependency Management
Lifecycle Management
Component Oriented Programming

Can you not see why it is beneficial? I mean really...?
Jeremy Liebherr
Greenhorn

Joined: Apr 25, 2007
Posts: 2
Peter what do you think frameworks are? They are implementations of design patterns. Struts = MVC design pattern and Spring = IoC design pattern.
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
>Can you not see why it is beneficial? I mean really...?

Since I never used it, I can't see the necessity . What you listed sounds interesting and it might facilitate but (forgive me) I just can't see HOW this will help.

Do you know of any concrete example that exemplify the need for spring.

thank you both for you help
Jeremy Liebherr
Greenhorn

Joined: Apr 25, 2007
Posts: 2
Peter,

After reviewing your previous posts I get the feeling that you have never heard of Google or doing any kind of research. Personally I tend to frown upon individuals who give little effort and immediately looks to others for a hand out. If you were to search on "Why use Spring Framework?" you would find exactly what you are looking for, a hand out. I believe that forums are for individuals who truly have issues and have put the time in and are now banging their head against the wall. So when I see that effort is put forth without a solution found I am happy to help but when someone continues to complain about the explanations of others when a clear answer is available with a little research I almost have to pity that person. So please save us all some time and do some research before faulting and posting lame questions.

Thank you.
Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Dear Jeremy,

>I almost have to pity that person. So please save us all some time and do >some research before faulting and posting lame questions.

As a reminder, when you joined this forum, you signed the agreement: BE NICE! so if you can't do that, I advise you not to post.

My question was sincere and valid! I was also generous and polite. I requested if anyone has a good example of struts-spring so he can advise a newbie.

Your last comment is clearly out of line and doesn't contribute to this forum.
Mark Manns
Greenhorn

Joined: Jul 06, 2006
Posts: 14
Hi Peter

I downloaded appfuse --- a spring kickstart. I used the spring MVC rather than struts. I think if you're going to use Spring you might want to think about dropping struts all together. Spring will allow you to uncouple your business classes from the service classes via dependency injection - which is nice. It will also give you aspects so you can configure stuff like logging without having to pollute your business classes with code to do logging. Spring MVC goes a step farther than struts in that it will populate your backend model classes via the Command object - which saves you from having to create a model object in your controller class and then populate it with values from the struts ActionForm.

Just my $.02.
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 512
Hi there,
As everyone has suggested spring can help you loosely couple the action classes and their dependencies mainly on Business Delegates and Service locators. I think that is the important thing you should look at. Beside this there are other advantages as - singleton,lifecycle management of the objects. One more thing you introduce Aspects into your spring beans (action classes,Business delegates and all other POJOs you might use).
Apart from this I can also think of other things such as
- if you are using a Hibernate DAO layer (which we have used earlier),you create the sessionfactory declaratively using spring configuration and then inject it in any spring bean and use it.
I am able to gather this much at this time
regds
amit


Regards,
Amit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts and spring