Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where does MVC determine you generate string content?

 
Steve Line
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic