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