• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Dispatch Action Equivalent in Spring?

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts 2 provides dynamic method invocation.
 
author
Posts: 422
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
tapeshwar sharma
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
reply
    Bookmark Topic Watch Topic
  • New Topic