Probably there were numerous topics on MVC and Struts, but I am starting this one again. :-)
There are many thoughs on applying MVC architecture to Web, and there is no one common and correct answer. My question is a bit different.
How usually are YOU working with Struts?
I am using:
"View" --- JSP/HTML pages. The can access getters of "data" bean. They can have links/forms *.do "Controller" --- classes which extends Action. I am usually implement all business logic there. Connecting to database, etc., etc., etc. Then it also use setters in "data" bean and then redirects where necessary. "Model" --- it's our "data" bean, class which extends ActionForm , with getters and setters. It's doing nothing, just keep data.
What about you?
Of course, I understand that we can't assign so special actions to MVC. But we need to "understand" all these Model, View and Controller at least to ourself!
Will be waiting for your responses! It really interesting how are you building your Struts applications. Thank you in advance! [ October 10, 2004: Message edited by: Olexiy Prokhorenko ]
<a href="http://www.BossTalks.com" target="_blank" rel="nofollow">http://www.BossTalks.com</a><br />Free advices and help for entrepreneurs: from Idea to IPO<br />Software and IT Project Management forum
In my view Action forms are not exactly part of Model. In MVC model is place where your business logic consist.
In action forms there is nothing to do with Model.
Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Joined: Jul 11, 2004
Sorry, may be I was not very clear in my question.
I mean - where do you keep business logic in your Struts stuff? In class extending Action? In class extending ActionForm? In JSP's?
Certainly, if we will try to assign MVC to Struts we probably could get that Model is partly class extending Action + class extending ActionForm, View is JSP/HTML, and Controller is partly class extending Action. But that's like neverending story. Everybody have own opinion on this topic, and we can argue about theory all the time, however, all of us will be right.
But the question is -- how do you use Struts in real-life applications? on practice? Where do you you keep your BUSINESS LOGIC?
"Controller" --- classes which extends Action. I am usually implement all business logic there. Connecting to database, etc., etc., etc. Then it also use setters in "data" bean and then redirects where necessary.
This what the user guide says:
For the simplest applications, an Action object may sometimes handle the business logic associated with a request. However, in most cases, an Action object should invoke another object, usually a JavaBean, to perform the actual business logic. This lets the Action focus on error handling and control flow, rather than business logic. To allow reuse on other platforms, business-logic JavaBeans should not refer to any Web application objects. The Action object should translate needed details from the HTTP request and pass those along to the business-logic beans as regular Java variables.
"Model" --- it's our "data" bean, class which extends ActionForm , with getters and setters. It's doing nothing, just keep data.
This what the user guide says:
While ActionForm beans often have properties that correspond to properties in your Model beans, the form beans themselves should be considered a Controller component. As such, they are able to transfer data between the Model and View layers.
I have not taken the trouble to explain the above in my own words, but I hope this information answers your question. Sheldon Fernandes [ October 11, 2004: Message edited by: Sheldon Fernandes ]