• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why not pass ActionForm instance to Model

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Why shouldn't we pass ActionForm instances to the Model. I read somewhere that it causes high coupling. If true, so what.

I am not able to understand the practical dis-advantages of passing an ActionForm instance. What problems may it cause?

regards,
vijay.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a scenario that might help explain it:

Say you decide to ignore the advice and pass your ActionForms as parameters to your model classes. Everything will work great, all is well, life is good.

Until.....

Your boss or client comes to you and says, "The CEO read in a airline magazine that JSF with AJAX is really the way to go, and Struts is really out of date. I want you to convert this application to JSF and Ajax."

You're thinking: OK, it's cool, I've used Model/View/Controller. I can just take the Model code that I've written and plug it into a JSF view.

Wrong!!

Since you made your Model class dependent on a Struts class (org.apache.struts.action.ActionForm) as soon as you remove struts.jar from your project, the model classes will no longer compile. You now have the choice of leaving the struts.jar file in the project just to make the project compile, or change your model classes.

The moral of the story: Tightly coupling your model classes with Struts or any other view framework is a bad thing.
[ July 05, 2006: Message edited by: Merrill Higginson ]
 
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OMG! I have my every model extend ActionForm and did something like...

public class Applicant
{
NameFormBean name;
ApplicationInfoFormBean applicationInfo;
}

where all those members extend ActionForm!!!
 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic