Re: Organizing action classes
Michael Jouravlev wrote: Chamal, if you decide to use a dispatch action, I suggest EventDispatchAction, or ActionEventDispatcher if your action class must inherit from your custom class. See these links: Definitely agreed there... this is, to me at least, clearly the best alternative if you go the Dispatch route. Michael. Frank - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Organizing action classes
I'll suggest wite a dispatch action and provide a actionmapping and call the corresponding method in the Your action class. On 6/8/06, chamal desilva <[EMAIL PROTECTED]> wrote: Hi, I have few action mapings. /get_admin_tasks /add_task /ass_user etc. /get_add_data /save_customer_data /save_account_data etc. Is it necessary to write Action classes for each of these actions or can we group several actions in to one Action class. What is the best way to organize actions in to action classes. Thanking You, Chamal. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- --- Suresh babu S Software Engineer IBM,080-417 72568(Direct) +91-9886237127 [EMAIL PROTECTED]
Re: Organizing action classes
On 6/7/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: You ask a question that is frequently debated around here :) I can say with quite a bit of confidence that Michael Jouravlev will be around shortly to say DispatchActions are the ONLY way to go :) Not the only way, just the one preferred by me :) 1) First off, it is possible to have several mappings and one action class, using MappingDispatchAction. Speaking of Frank and me, there are no real benefits in this approach: * Frank does not like having one large action class * I don't like having several mappings 2) My approach is having one mapping and one action class. This is not just "more simple actions" vs "more methods in one action" debate. * With one mapping you have one URL, that may be important for some, especially if you redirect an action to itself. * With one action class and one form bean and possibly with one nested business object you have clear relationship between a business object, a web resource and a web-related code, sort of code-behind class in .Net-speak. If your form bean is session-scoped, then it is very easy to keep the conversation, and to send different events to the same web resource, updating its state. * Conceptually, a dispatch action represents a whole web resource, while its methods represent possible actions on the web resource, a clean paradigm. * Less mappings in xml file, less clutter. I prefer to have one action class and one mapping for all submit events as well as for rendering, but many find it too complex. It may be simpler to use dispatch action to submit events, and to use another regular action to render a view. Thus, a web resource would be served with two actions. Chamal, if you decide to use a dispatch action, I suggest EventDispatchAction, or ActionEventDispatcher if your action class must inherit from your custom class. See these links: http://wiki.apache.org/struts/EventActionDispatcher http://wiki.apache.org/struts/DataEntryForm Michael. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Organizing action classes
You ask a question that is frequently debated around here :) I can say with quite a bit of confidence that Michael Jouravlev will be around shortly to say DispatchActions are the ONLY way to go :) I'm in the same camp as Adam though... I find that code is better organized when each Action serves one function. If you work in a team environment, it also tends to make it a little easier to coordinate efforts (note hugely so, but enough that I prefer it). Some say that more classes makes the overall system more difficult to understand. There certainly is something to that, however, proper packaging can largely alleviate that problem (i.e., don't have one big Actions package with all your Actions, break it up into functional groups so you have a few Actions in each group). In the end though, it really largely just comes down to preference, and what your own experience tells you. There isn't at this point any clearly defined "best practice" in this regard, not that I'm aware of anyway. So, no, to answer your question directly, it is definitely NOT required to write separate actions for each mapping. Whether that's the best approach or not is a much more difficult question to answer :) Frank chamal desilva wrote: Hi, I have few action mapings. /get_admin_tasks /add_task /ass_user etc. /get_add_data /save_customer_data /save_account_data etc. Is it necessary to write Action classes for each of these actions or can we group several actions in to one Action class. What is the best way to organize actions in to action classes. Thanking You, Chamal. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Organizing action classes
Depending on what version of Struts you are using, you could check out org.apache.struts.actions.DispatchAction and it's subclasses. For the sake of maintainability and readability though I generally prefer to keep a 1 to 1 between action subclasses and path mappings, factoring common functionality into base action classes or helpers. Just personal opinion though. -Adam chamal desilva wrote: Hi, I have few action mapings. /get_admin_tasks /add_task /ass_user etc. /get_add_data /save_customer_data /save_account_data etc. Is it necessary to write Action classes for each of these actions or can we group several actions in to one Action class. What is the best way to organize actions in to action classes. Thanking You, Chamal. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Organizing action classes
Hi, I have few action mapings. /get_admin_tasks /add_task /ass_user etc. /get_add_data /save_customer_data /save_account_data etc. Is it necessary to write Action classes for each of these actions or can we group several actions in to one Action class. What is the best way to organize actions in to action classes. Thanking You, Chamal. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]