Date: 2004-09-24T09:57:44
   Editor: MichaelMcGrady <[EMAIL PROTECTED]>
   Wiki: Apache Struts Wiki
   Page: StrutsCatalogFiveMultipleButtonSolutions
   URL: http://wiki.apache.org/struts/StrutsCatalogFiveMultipleButtonSolutions

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -1,12 +1,55 @@
 ##language:en
+== PREFACE ==
+
+=== Notes ===
+
 This presentation is somewhat detailed, so we begin with a Table of Contents for your 
ease in navigating the presentation.  Enjoy!  There is a comment section at the very 
end.
 
 The desire of people to add to this wiki is extremely gratifying.  In order to better 
accommodate this need and to maintain some "order" and "look" to this presentation, I 
have added a section at the end for links to other solutions.  Please do feel free to 
add your own ideas there.  Please follow the "look and feel" and format of the wiki.  
 
+=== Discussion ===
+
+Presently there are two somewhat popular and different solutions to buttons in Struts 
and generally.  They are the ImageButtonBean solution and the DispatchAction 
solutions.  Both suffer from over-engineering in serious ways.  
+
+The initial problem was to determine which of multiple tags in a from was pressed, 
e.g.
+
+{{{
+<input type='image' name='update' src='enter.gif'>
+<input type='image' name='delete' src='nuke.gif'>
+<input type='image' name='clear'  src='clear.gif'>
+}}}
+
+Essentially ImageButtonBean utilizes the fact that <input type='image' name='input' 
src='save.gif'> creates two name/value pairs in the request object with suffixes, viz. 
input.x=85 and input.y=93, for example.  Using the Struts framework and reflection, 
this is used to call, for example, new ImageButtonBean().getInput().getX() and, 
'''if''' this is not empty, we know that the input tag was clicked.  The 
ImageButtonBean, unfortunately, requires that at least one object to be created for 
each command in the application, and this is just too heavy a load.  Additionally, 
this solution requires that we use, e.g., "input.x" for method calls when we have a 
simpler solution in just obtaining the prefix to this name in the name/value request 
object pair in the first place.
+
+The DispatchAction solutions are based on using the struts-config.xml to mine the 
value of these tags.  This too is over-engineering and overkill, even though with 
MappingDispatchAction there are different uses for this sort of algorithm.  We provide 
alternative solutions that do all that the DispatchAction classes do without incurring 
their overhead and their coupling to Struts.
+
+There is the further problem of providing some sort of a generic solution.  The work 
on this page is but a small part of a much bigger solution that will soon be 
presented.  I use the following for my buttons:
+
+
+                               <crackwillow:image
+                                       button='Crack_Willow_Chat.gif'
+                                       mapBean='hkc'
+                                       bgClrCode='banRtBgClr'
+                                       txtClrCode='banRtTxtClr'
+                                       font='Edwardian Script ITC'
+                                       italic='false'
+                                       bold='true'
+                                       size='30'
+                                       property='chatSend.dispatch'/>
+
+This tag creates the button Crack_Willow_Chat.gif dynamically and caches it with the 
attributes listed.  Eventually this will be added to this page.  The main point, 
however, is that we get rid of the over-engineering and obtain "input" from "input.x" 
rather directly.  For those who like the ImageButtonBean approach, more efficient ways 
to do this sort of thing are presented on this page, requiring only a single button 
that exists only for the life of a call, for example.
+
+Please do add your ideas at the end.  Because much more is coming to this page, not 
putting something in the middle would be appreciated.
+
+'''-- Michael !McGrady '''
+
 == Table of Contents ==
 {{{
-1     Table of Contents
-2     PROBLEM: Universal Button Solutions: --------------- PROBLEM
+1     PREFACE
+1.1   Notes
+1.2   Discussion
+2     Table of Contents
+3     PROBLEM: Universal Button Solutions: --------------- PROBLEM
       SOLUTIONS: ----------------------------------------- SOLUTIONS
       I.   Action Solution
              A.   DispatchUtil (SOLUTION ONE)
@@ -17,38 +60,38 @@
              ButtonForm (SOLUTION FOUR)
       IV.  Button Solution
              Button (SOLUTION FIVE)
-3     Tag Uses
-3.1   Action Class Code
-3.2   Mulitiple Image Tags
-3.3   Link Tags
-3.4   Submit Tags
-3.5   File Browse Tags
-3.6   Button Tags
-3.7   struts-config.xml Uses
-3.7.1 MappingDispatchAction
-3.7.2 LookupDispatchAction
-4     SOLUTION ONE: DispatchUtil Code -------------------- SOLUTION ONE
-5     (new) DispatchAction
-5.1   Discussion
-5.2   SOLUTION TWO: (new) DispatchAction Code ------------ SOLUTION TWO
-6     PAO (Plain Actino Object): Solution for Tags without Dispatch, without 
Reflection, without ActionMapping or Even without Struts
+4     Tag Uses
+4.1   Action Class Code
+4.2   Mulitiple Image Tags
+4.3   Link Tags
+4.4   Submit Tags
+4.5   File Browse Tags
+4.6   Button Tags
+4.7   struts-config.xml Uses
+4.7.1 MappingDispatchAction
+4.7.2 LookupDispatchAction
+5     SOLUTION ONE: DispatchUtil Code -------------------- SOLUTION ONE
+6     (new) DispatchAction
 6.1   Discussion
-6.2   SOLUTION THREE: ButtonTagUtil Code ----------------- SOLUTION THREE
-7.    ButtonForm
+6.2   SOLUTION TWO: (new) DispatchAction Code ------------ SOLUTION TWO
+7     PAO (Plain Action Object): Solution for Tags without Dispatch, without 
Reflection, without ActionMapping or Even without Struts
 7.1   Discussion
-7.1.1 Only One Button Object (Immediately Destroyed)
-7.1.2 Button Command Determined by Button Name and not getX() or getY()
-7.1.3 Clean Up and Reset of the Action Form Occasioned by getX() or getY()
-7.2   SOLUTION FOUR: ButtonForm Code --------------------- SOLUTION FOUR
-8.    Button
+7.2   SOLUTION THREE: ButtonTagUtil Code ----------------- SOLUTION THREE
+8.    ButtonForm
 8.1   Discussion
-8.2   SOLUTION FIVE: Button Code ------------------------- SOLUTION FIVE
-9     Links
-10    Comments (Peanut Gallery)
-11    Author
-12    Other Solutions
-12.1  Links to Other Solutions
-12.2  Let's Hear from You
+8.1.1 Only One Button Object (Immediately Destroyed)
+8.1.2 Button Command Determined by Button Name and not getX() or getY()
+8.1.3 Clean Up and Reset of the Action Form Occasioned by getX() or getY()
+8.2   SOLUTION FOUR: ButtonForm Code --------------------- SOLUTION FOUR
+9     Button
+9.1   Discussion
+9.2   SOLUTION FIVE: Button Code ------------------------- SOLUTION FIVE
+10    Links
+11    Comments (Peanut Gallery)
+12    Author
+13    Other Solutions
+13.1  Links to Other Solutions
+13.2  Let's Hear from You
 
 }}}
 == Universal Button Solutions ==

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

Reply via email to