GeeCON Prague 2014*
The moose likes Spring and the fly likes Dispatch Action Equivalent in Spring? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Dispatch Action Equivalent in Spring?" Watch "Dispatch Action Equivalent in Spring?" New topic
Author

Dispatch Action Equivalent in Spring?

tapeshwar sharma
Ranch Hand

Joined: Mar 10, 2006
Posts: 245
Hi Craig,
I used Struts 1.2 heavily before switching over to Spring MVC since Spring 2.0.
However, I have not been able to find an equivalent yet for the DispatchAction in Struts 1.2.
Actually, not even in Struts 2.0 for that matter.
I find DispatchAction really helpful and efficient for CRUD like operations.
Does Spring 3.0 provide some Controller like that or is there an easy work around for that ?
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
tapeshwar sharma wrote:Hi Craig,
I used Struts 1.2 heavily before switching over to Spring MVC since Spring 2.0.
However, I have not been able to find an equivalent yet for the DispatchAction in Struts 1.2.
Actually, not even in Struts 2.0 for that matter.
I find DispatchAction really helpful and efficient for CRUD like operations.
Does Spring 3.0 provide some Controller like that or is there an easy work around for that ?


Google search yielded this link although it is for Spring 2.0

SCJP 1.5, SCEA, ICED (287,484,486)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Struts 2 provides dynamic method invocation.
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
That link that Anil gave is in regard to Spring's MultiActionController...which is quite similar to Struts' DispatcherServlet. That's one way of doing it, I suppose. But the new Spring @MVC model lets you do the same thing without implementing/extending any special controller. For example, consider this annotated controller:



(Note that I wrote this controller on-the-fly...I've not actually tried it...there may be some mistakes.)

This single controller responds to 3 kinds of requests:
- Requests for "/book/list" to display a list of all books
- GET requests for "/book/{bookId}" to display details for a given book ID
- DELETE requests for "/book/{bookId}" to delete a given book

Notice the RESTful-ness of this controller. It's not exactly the same as DispatchAction or MultiActionController...but I think it's something much better.


Spring in Action - Unleash POJO power in your applications!
Modular Java - Discover the secret weapon to modularity on the Java platform!
XDoclet in Action - Your complete guide to code generation with XDoclet.
tapeshwar sharma
Ranch Hand

Joined: Mar 10, 2006
Posts: 245
Craig Walls wrote:That link that Anil gave is in regard to Spring's MultiActionController...which is quite similar to Struts' DispatcherServlet. That's one way of doing it, I suppose. But the new Spring @MVC model lets you do the same thing without implementing/extending any special controller. For example, consider this annotated controller:



(Note that I wrote this controller on-the-fly...I've not actually tried it...there may be some mistakes.)

This single controller responds to 3 kinds of requests:
- Requests for "/book/list" to display a list of all books
- GET requests for "/book/{bookId}" to display details for a given book ID
- DELETE requests for "/book/{bookId}" to delete a given book

Notice the RESTful-ness of this controller. It's not exactly the same as DispatchAction or MultiActionController...but I think it's something much better.


Hmm...this might workout . Thanks, though I am yet to explore that whether the Restful version has any side-effects.
It forces to stick to particular url format for one.But then it may not be a problem.
For the record, MultiActionController does not support the Command object. Not at least directly.
There is a Command controller but that does not support multi-operations.
This is the reason that MultiActioncontroller can not fill-in for DispatchAction without a workaround.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dispatch Action Equivalent in Spring?