It's not a secret anymore!*
The moose likes Struts and the fly likes Where does MVC determine you generate string content? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Where does MVC determine you generate string content? " Watch "Where does MVC determine you generate string content? " New topic
Author

Where does MVC determine you generate string content?

Steve Line
Greenhorn

Joined: Mar 27, 2005
Posts: 18
Hi There -

We have a debate on our project about where string content should be generated . If there's a message that should be displayed to the user, it's easier for the action class to save a string in a form bean and have the jsp retrieve the string from the bean and display it. However a member of our team has convinced the team lead that we should merely pass flags in the bean and the jsp will have a series of c:if statements that will check the flags and display the appropriate string message. that way all string content is in the presentation layer and not in the model.

I prefer the first method because there's less coupling between model and presentation and it's more flexible for adding new messages.

How would an MVC expert decide this?

Steve
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
MVC expert? Is there such a thing? I think that most Struts developers lump Form Beans into the View category. It is not the Model. The Model is more your database or business objects.

Then again, I would never advocate blindly following a pattern. Stop and think about how much additional work the approach that your fellow team mate causes. Patterns are in place to make your job easier, not to make more work. Adding all that logic to your JSP seem foolish to me. My view is that a JSP should be as close to HTML as possible and that anytime you can remove logic from a JSP and move it into the Action Form you are better off.

If your tech lead needs a pattern to justify your actions, tell him that you are using the View Helper pattern: http://java.sun.com/blueprints/corej2eepatterns/Patterns/ViewHelper.html

- Brent
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Where does MVC determine you generate string content?
 
Similar Threads
When using MVC, to what degree should a model be tailored to a view?
Is this MVC?
Mark's MVC design - all controller methods private?
Topic: Struts and MVC. Question: how usually are working you?
Business Tier + Persistence Tier