RE: Model and Controller Components
-Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Montag, 10. Februar 2003 08:26 To: Kashinath Cc: Struts Users Mailing List Subject: Re: Model and Controller Components If you find documentation in Struts that talks about form beans being model objects, please point them out specifically -- that documentation is wrong, and needs to be corrected. Craig McClanahan I found the following books that describe the situation wrong or at least unclear: Professional JSP, 2nd Edition, Wrox Press (ISBN 1-861004-95-8) (www.wrox.com) says in chapter 21, page 781 in a component diagram: Action (model's business logic) ActionForm (model's data) An more clearly: ...ActionForm - This is an MVC Model component... ...Action - This class represents the business logic and is part of the MVC Model component --- My german book Java Server Pages und J2EE (ISBN 3-89864-112-0) from dpunkt.verlag (www.dpunkt.de) also has a chapter about Struts. On page 153 the describe the elements in details, too. Stating that JSP=view, ActionForm=model,Action=controller. At least here the Action is part of a more specialised controller delegating to the business logic. --- I suppose every book author who didn't write a specialized book about Struts but only a chapter, somehow got it wrong. Hope that helps a bit to clarify things in future. I would suggest drawing a component diagram for the struts documentation and clearly point out that a) business logic should be in the Action b) ActionForms are for view purposes. Mostly people got it wrong because the self-made diagrams of some book authors depict the situation wrong. By the way... I'm in doubt now, too... Until now I considered ActionForms as models, too. Thanks to all those books... ;-) So I guess it's a bad design idea to let my business logic (which is out of Action already) manipulate the ActionForm directly... Correct? Until now I have business logic JavaBeans with setter methods to give the current ActionForm to the busines logic in order to store the data from business layer in that form for later view purposes. Would it be okay, to let my business logic beans store their own data first and should I let some code in the Action class do the job of moving the business logics data into the ActionForm manually instead of giving the business logic a reference to the whole ActionForm? Thanks Michael - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Model and Controller Components
On Mon, 10 Feb 2003, Kashinath wrote: Date: Mon, 10 Feb 2003 10:48:45 - From: Kashinath [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED], Kashinath [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Model and Controller Components Hi, In struts what are model components and what are controller components? ActionServlet is controller component but how Action is controller can any one explain me? Again according to the documentation ActionForm is model component. Precisely where do you see this (so we can fix it)? ActionForm is a view component, IMHO. How? Can any one componentise the model and controller components? Actions should be controller components that delegate the actual transactional logic to appropriate business objects, although for simple applications it is often easier to just program your business logic directly into the actions. Struts doesn't have any model tier model per se; it will work with whatever you like. Kasinath VisualSoft Technologies Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Model and Controller Components
thanks a lot Craig for your information. Craig what is your view on ActionForm as Model. Is it a model? kasi - Original Message - From: Craig R. McClanahan [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED]; Kashinath [EMAIL PROTECTED] Sent: Monday, February 10, 2003 5:27 AM Subject: Re: Model and Controller Components On Mon, 10 Feb 2003, Kashinath wrote: Date: Mon, 10 Feb 2003 10:48:45 - From: Kashinath [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED], Kashinath [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: Model and Controller Components Hi, In struts what are model components and what are controller components? ActionServlet is controller component but how Action is controller can any one explain me? Again according to the documentation ActionForm is model component. Precisely where do you see this (so we can fix it)? ActionForm is a view component, IMHO. How? Can any one componentise the model and controller components? Actions should be controller components that delegate the actual transactional logic to appropriate business objects, although for simple applications it is often easier to just program your business logic directly into the actions. Struts doesn't have any model tier model per se; it will work with whatever you like. Kasinath VisualSoft Technologies Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Model and Controller Components
On Mon, 10 Feb 2003, Kashinath wrote: Date: Mon, 10 Feb 2003 11:25:45 - From: Kashinath [EMAIL PROTECTED] To: Craig R. McClanahan [EMAIL PROTECTED], Struts Users Mailing List [EMAIL PROTECTED] Subject: Re: Model and Controller Components thanks a lot Craig for your information. Craig what is your view on ActionForm as Model. Is it a model? Absolutely *not*. As the original creator of Struts, who designed it the way it is for a reason, I hope you will take this statement seriously. ActionForm is part of the view tier -- it's only purpose in life is to represent the server-side state of the current values that the user has typed on an input form. For example, consider a field that (in your database) is an integer. What should happen if the user types 1a3 instead of 123 into the corresponding text field? * The validation checking should catch this problem and create an appropriate error message. * The input page should be redisplayed (along with the error messages, *including* the 1a3 value that the user originally entered. That is the way GUI programs work, and that is what webapp users expect as well. In order to accomplish this, Struts strongly recommends that the JavaBean property for an integer field in your ActionForm bean should be a String -- that's the only way you can reproduce exactly what the user originally typed if he or she makes a mistake. In your Action that processes the input form, after validations have proven that you can successfully convert this String into an integer, *that* is where you should convert to native datatypes in a value object (or whatever other mechanism you are using to communicate with your business logic). Investigate the BeanUtils.copyProperties() method for painless copy-and-convert functionality of all the properties in a form bean into corresponding native properties in a value object. For lots and lots more information about this topic, you can search the mailing list archives for discussions of ActionForm and the three tiers, or read any of the recent books about Struts. If you find documentation in Struts that talks about form beans being model objects, please point them out specifically -- that documentation is wrong, and needs to be corrected. kasi Craig McClanahan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]