Date: 2004-09-19T06:46:25
Editor: MichaelMcGrady <[EMAIL PROTECTED]>
Wiki: Apache Struts Wiki
Page: StrutsCatalogDispatchUtil
URL: http://wiki.apache.org/struts/StrutsCatalogDispatchUtil
no comment
Change Log:
------------------------------------------------------------------------------
@@ -1,4 +1,18 @@
##language:en
+== Table of Contents ==
+{{{
+2. Universal Button Utility for Struts
+3. Uses
+3.1 Mulitiple Image Tags
+3.2 Link Tags
+3.3 Submit Tags
+3.4 File Browse Tags
+3.5 Button Tags
+3.6 struts-config.xml Uses
+3.6.1 MappingDispatchAction
+3.6.2 LookupDispatchAction
+
+}}}
== Universal Button Utility for Struts ==
There is a persistent problem of handling multiple buttons, and this is especially a
problem when the buttons are images. Struts has provided a solution for this with
DispatchAction and its progeny. There are various other solutions. I have provided
one at StrutsCatalogImageTagUtil. I have actually provided two solutions there. The
following solution is, I think, superior in every way. What it does is to merge the
best parts of StrutsCataglogImageTagUtil and DispatchAction.
@@ -9,38 +23,41 @@
'''N.B. the uses of "dispatch".''' If you do not like using "dispatch", then you can
rewrite the code in the getMethodName(...) method. Essentially, you will need to
replace ".dispatch" with something else in the tag names which you can identify in the
enumeration. You have to use a suffix with this logic. But, if you want a prefix,
e.g. "dispatch.update" or "method.update", then you will have to change the logic too.
Suffix logic seems to best fit the existing methods in String. Otherwise, I would
have used a prefix. You may want to anyway.
-=== Multiple Images ===
+=== Multiple Image Tags ===
Multiple image tags are the primary reason for this class. Integrating this into a
common solution is the difficulty.
{{{
<input type='image' name='update.dispatch' src='update.gif'>
<input type='image' name='delete.dispatch' src='delete.gif'>
}}}
-=== Links ===
+=== Link Tags ===
{{{
<a href='profile.do?update.dispatch=whatever'>
<a href='profile.do?delete.dispatch=whatever'>
}}}
-=== Submits ===
+=== Submit Tags ===
{{{
<input type='submit' name='update.dispatch' value='whatever'>
<input type='submit' name='delete.dispatch' value='whatever'>
}}}
-=== File Browse ===
+=== File Browse Tags ===
{{{
<input type='file' name='update.dispatch'>
<input type='file' name='delete.dispatch'>
}}}
-=== Button ==
+=== Button Tags ===
{{{
<input type='button' name='update.dispatch' value='whatever'>
<input type='button' name='delete.dispatch' value='whatever'>
}}}
-=== struts-config.xml ===
+=== struts-config.xml Uses ===
If you like to do things the way they are done with DispatchActions and use Struts
xml for commands, then the following are possibilities. '''Please note that you never
have to do this. Struts xml configuration is wholly voluntary for this solution.'''
-==== MappingDispatchAction ===
+==== MappingDispatchAction ====
+
+This solution depends not on the value of the name attributes in the html tags, but
strictly on the value of the path attributes in the html tags, anytime
/updateProfile.do is called in the example below, any name attributes will be
overridden and the value of the ActionMapping property called "parameter" will be
operative instead.
+
{{{<action path="/updateProfile"
type="org.example.ProfileAction"
parameter="update.dispatch"
@@ -60,6 +77,10 @@
<forward name="success" path="/deletedSubscription.jsp"/>
</action>
}}}
+==== LookupDispatchAction ====
+
+(TODO)
+
== Code ==
{{{
package com.crackwillow.struts.util.dispatch;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]