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

J

John

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
 
R

Richard Senior

John said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top