aspose file tools*
The moose likes Struts and the fly likes Multiple Views, Single Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple Views, Single Action" Watch "Multiple Views, Single Action" New topic
Author

Multiple Views, Single Action

Bloo Barton
Ranch Hand

Joined: May 09, 2005
Posts: 63
In general it seems that the rule is for each View there is a corresponding Action. This is part of our traditional MVC design pattern.

However, I have several different Views that essentially perform the same Action on form submission. Is there anything wrong in this case with having a many to one relationship, where I have many views to a single action? What are my pros and cons here?

thanks,
Bloo
Bloo Barton
Ranch Hand

Joined: May 09, 2005
Posts: 63
Or what if I have a seperate Action class for each view, but an additional CommonAction class that is called by the view specific Actions classes?
Pranav Sharma
Ranch Hand

Joined: Oct 27, 2003
Posts: 257
from what I understand, you could have 1-1 relationship for action and views. But this just increases number of action classes which may become unmanagable. So if most of your action classes are doin similar tasks on different views, you could use DispatchAction and reduce the redundant cut and paste code.
bottom line 1 view to many relationships is good for similar tasks
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Trying to map Struts to the traditional principles of MVC does not always make sense because Struts is not traditional MVC.

I'm not sure what you are referring to by "view". I assume you are referring to your jsps. There is nothing wrong with making more than one jsp call the same action but there's probably a good chance that you could take advantage of reusing your jsp.

Or what if I have a seperate Action class for each view, but an additional CommonAction class that is called by the view specific Actions classes?

I think that is not a good idea as it is an unnecessary chaining of Actions.


A good workman is known by his tools.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple Views, Single Action
 
Similar Threads
Hibernate and views
URLs in a Portlet
Certification Attack
Thumbnail
Bear's Frontman, The requested resource () is not available.