Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Newbie on Struts: What is the difference between the Model & the Form

Thread view: 
John - 26 Apr 2007 23:34 GMT
Hi everybody,
I am new to Struts, and I don't understand yet the difference between
Form classes and Model classes.

What I thought is that Form classes (extended from ActionForm)
represent the data to be transported between the View and the
Controller, and actually the Form can represent the Model in the MVC
Pattern.

But I saw J2EE projects with "form" packages and "model" packages, and
I do not understand why...

Can somebody explain me the difference, usage, and where am I wrong in
my assumption?

Thank you very much for your answers
John
Richard Senior - 27 Apr 2007 10:51 GMT
> What I thought is that Form classes (extended from ActionForm)
> represent the data to be transported between the View and the
> Controller

Correct.

> and actually the Form can represent the Model in the MVC
> Pattern.

It could, in the sense that you could shunt the Struts form all round
your application and right down into JDBC/persistence code. Apart from a
general type conversion headache (most fields on a Struts form should be
String), doing so would couple your application and its business logic
tightly to Struts.

Far better to deal only with your forms in the action class, delegating
your business logic to a business layer that you populate from the data
in the forms. Commons BeanUtils.copyProperties and
PropertyUtils.copyProperties will become your friends.

http://javaboutique.internet.com/tutorials/strictly_struts/
http://forum.java.sun.com/thread.jspa?threadID=555715&messageID=2902371

Signature

Regards,

Richard



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.