Date: 2004-09-19T06:31:44
   Editor: MichaelMcGrady <[EMAIL PROTECTED]>
   Wiki: Apache Struts Wiki
   Page: StrutsCatalogDispatchUtil
   URL: http://wiki.apache.org/struts/StrutsCatalogDispatchUtil

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -5,6 +5,61 @@
 
 This is a solution for Struts.  If you want a solution independent of Struts, again, 
please see StrutsCatalogImageTagUtil.  The principle reason for this class is the 
problem with <input type='image' name='whatever'> tags in HTML.  Those tag send the 
values in the name attribute as ''whatever.x=9'' and ''whatever.y=26''.  
DispatchAction and its progeny provide a melange of solutions but no common way to 
deal with ''<a href='whatever.do'>'', ''<input type='submit'>'', ''<input 
type='image'>'', ''<input type='file'>'', or whatever.  This class, DispatchUtil does 
that.  If you prefer to use a subclass, just provide the functionality in this class 
in a class extending Action.  Herbert Rabago came up with the idea of providing the 
functionality in a utility class and I really like that idea.  So, here we go.
 
+== Uses ==
+
+'''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 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 ===
+{{{
+<a href='profile.do?update.dispatch=whatever'>
+<a href='profile.do?delete.dispatch=whatever'>
+}}}
+=== Submits ===
+{{{
+<input type='submit' name='update.dispatch' value='whatever'>
+<input type='submit' name='delete.dispatch' value='whatever'>
+}}}
+=== File Browse ===
+{{{
+<input type='file' name='update.dispatch'>
+<input type='file' name='delete.dispatch'>
+}}}
+=== Button ==
+{{{
+<input type='button' name='update.dispatch' value='whatever'>
+<input type='button' name='delete.dispatch' value='whatever'>
+}}}
+=== struts-config.xml ===
+
+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 ===
+{{{<action path="/updateProfile" 
+          type="org.example.ProfileAction" 
+          parameter="update.dispatch"
+          name="profileForm" 
+          validate="true" 
+          input="/editProfile.jsp" 
+          scope="request">
+      <forward name="success" path="/updatedProfile.jsp"/>
+  </action>
+
+  <action path="/deleteSubscription" 
+          type="org.example.ProfileAction"
+          name="profileForm"
+          scope="request"
+          input="/subscription.jsp"
+          parameter="delete.dispatch">
+      <forward name="success" path="/deletedSubscription.jsp"/>
+  </action>
+}}}
 == Code ==
 {{{
 package com.crackwillow.struts.util.dispatch;

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

Reply via email to