R.Vijayaraghavan ha scritto:
Hello,

I usually have set and get methods for all properties in my Model class.
After submitting a form, I pull out all the property values (form fields) in
the Action class from the ActionForm object, set the values of all
properties in the model from the action class and then call a particular
method in the model class for final submission to the database.

I wanted to know thether the above mentioned method is better or is it
better to pass the form reference itself to the Model class which then sets
the values.

In situation 2, I do not have to take care of the various String references
that I create. I simply will pass the ActionForm object to the Model class.

regards,
vijay.



Ok I think we all should take a breath. Essentially there is not a "best" practice in how the controller should call the model. There are various techniques (session façades, business delegates, IoC...) but anyway the controller is responsible to call the model. All of these techniques, anyway, show their purpose to hide the fact that the model is used by a web-app. From my point of view, I think that IoC is the best way to call the model, because it reduces the levels of indirection in a cleaner way, but you have to use Spring or another IoC engine. Anyway notice that the ActionForm is part of Struts and should not be referenced inside your model (though I once used it as a simple bean and took away its
property values by using BeanUtils, I don't know how correct it is...)

Just my 2 eurocents
Ciao
Antonio Petrelli

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to