On 7/25/05, Rick Reumann <[EMAIL PROTECTED]> wrote: > starki78 wrote the following on 7/25/2005 2:04 AM: > > Hi, I've tested both types of actions but I really > > cannot say which action is better and I don't have the slightest > > feeling when which action to take. > > Without trying to open up a whole other can of worms since there have > been a bunch of recent threads concerning the dispatch/lookup concept, I > would stay away from the LookupDispatchAction. There are other variants > out there MappingDispatchAction, SimpleDispatchAction, and now > SelectAction. Personally, I've just stuck with DispatchAction and like > it. The other new flavors mentioned have some merit, but since you asked > about LookupDispatchAction I'll reiterate again why I hate it... > > 1) Figuring out what method gets called when you press a button is way > too annoying. You have to define a map in your Action class which > represents the names of the buttons, but if you use your > ApplicationResources file to have the names display on you page, you > know have to do this translation to figure out what gets called... you > need to look in the app resources file and then look in the map and find > that key represented by the value in app resources and then you can see > the method being called.
Having the map right in an action file is easier, faster and does not tie you to a property file, does it? > 2) It makes it difficult for your button to do perform more than one > type of action. For example, maybe you have a generic button used on a > from that can be used for a couple different actions methods. If you > call it "submit" it's only going to what 'submit' equates to in the > Lookup map in your Action. If you use a Dispatch Action you can have > your button do more than one type of action method since it's not keyed > off the button name. I don't see how it is different. In the end of the day it is just a request parameter, and you can do whatever you want with it. DispatchAction uses "method=methodName" to obtain method name. LookupDispatchAction uses a map, but you still can change the request parameter. Also, indirection gives you some sort of protection, because users do not know about actual method names, and they cannot call any public method of action class on their choice. I think having an indirect call is a little more robust. > 3) There are issues when you have more than one submit button on a page > and the user presses enter on their keyboard. I forgot the exact > problems but it was a real pain. In IE it acts one way, in other > browsers a different way. I just remember cases where the button name > being passed wasn't what was expected. I was testing default submit yesterday. I have two sample apps, both use form, text field and some buttons. Firefox always submits the first button, defined in the form. IE submits the first button in one case, and does not submit any buttons in other case. I don't know why. Therefore I decided to use a hidden field which contains default event in case no buttons are submitted. Michael. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]