File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes MVC without Struts: A doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Struts
Reply Bookmark "MVC without Struts: A doubt" Watch "MVC without Struts: A doubt" New topic
Author

MVC without Struts: A doubt

Yash Sharma
Ranch Hand

Joined: Jan 30, 2003
Posts: 61
I have been busy dealing with a MVC framework of my own. I have defined an abstract Action class, based on which I create concrete Action classes (for eg: CreateUserAction).


Model here is some user defined class or bean. I wonder why we need to have a bean to put my business logic in, can't I put it inside my concrete action classes itself. For instance, instead of doing a model.createUser() I could perhaps write the logic in the perform method itself. Does it dilute the MVC model, if I do so?

I had read that writing an if-else contructs to redirect request based on the "action" requested makes ugly code and hence the concept of keeping a map of all action classes and loading them dynamically. But I fail to see how the controller servlet can avoid writing such constructs in order to write code to handle redirects based on responses.

Example, for a simple login authentication:


If I have a dozen actions in my application which return result as strings. Assuming that for each database related operation of Add/Modify/Delete there will thus be 6 such results depending on their SUCCESS/FAILURE Iwill perhaps end up having 72 such if-else constructs.

Is this observation correct or my approach of getting the results as String is wrong?

Thanks for your time.
 
 
subject: MVC without Struts: A doubt
 
Threads others viewed
RequestDispatcher.forward problem
Model 2 Controller/Action Design
Classes
Web Application Framework
sun example Model datatype
IntelliJ Java IDE