Michael McGrady wrote the following on 9/14/2004 2:26 PM:

Any way, I have something else on this. Rick, I have written a class I call SimpleDispatchAction which allows you to use links, submits, and images with the same code without involving struts-config.xml in the process. I put it up at http://wiki.apache.org/struts/StrutsCatalogSimpleDispatchAction if you want to see it. All you have to do is to make sure that the name in your name value pair ends with .x. So

   *LINKS:*

<a href='update.do?update.x=update'>UPDATE</a>
<a href='update.do?update.x=delete'>DELETE</a>


   *FORM SUBMITS:*

<input type='submit' name='update.x' value='update'>UPDATE
<input type='submit' name='delete.x' value='delete'>DELETE


   *IMAGES:*<input type='image' name='update' src='update.gif'>
   <input type='image' name='delete' src='update.gif'>

all work in this case without any value for the parameter attribute in DispatchAction or LookupDispatchAction. Does this do the job for you? Notice that you can change the update.x, for example, to method.update.x if you want to do the localization thing as in LookupDispatchAction. I probabley should do that next, if you don't find something amiss here.

Hey, yes that is pretty cool. One advantage still that the MappingDispatchAction has is that you have a cetnralized place to decide what method is called based on the action name. The above is super cool for form inputs but I'm a bit curious about how you would handle links?


For example with a MappingDispatchAction I may have a bunch of links throughout the application that look like:

<c:url var="url" value="/fooBar.do"/><a href="${url}">[ fooBar ]</a>

If I decide I want all these links to go a different dispatch method I simply change the parameter name in my struts-config for the mapping for "fooBar"

In your scenario, if you had several links that all looked like:

<a href='fooBar.do?boguz.x=boguz'>MY LINK</a>

How would you easily change what actual action method that ends up getting called? (without search and replace of "boguz" in your links?)

--
Rick

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



Reply via email to