Date: 2004-09-19T10:26:01
Editor: MichaelMcGrady <[EMAIL PROTECTED]>
Wiki: Apache Struts Wiki
Page: StrutsCatalogMultipleButtonSolutions
URL: http://wiki.apache.org/struts/StrutsCatalogMultipleButtonSolutions
no comment
Change Log:
------------------------------------------------------------------------------
@@ -1,9 +1,21 @@
##language:en
+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.
+
== Table of Contents ==
{{{
1 Table of Contents
-2 PROBLEM: Universal Button Solutions: SOLUTIONS: DispatchUtil, (new)
DispatchAction, ButtonTagUtil
-3 Uses
+2 PROBLEM: Universal Button Solutions: --------------- PROBLEM
+ SOLUTIONS: ----------------------------------------- SOLUTIONS
+ I. Action Solution
+ A. DispatchUtil (SOLUTION ONE)
+ B. (new) DispatchAction (SOLUTION TWO)
+ II. Non-Struts Solution
+ ButtonTagUtil (SOLUTION THREE)
+ III. ActionForm Solution
+ ButtonForm (SOLUTION FOUR)
+ IV. Button
+ Button (SOLUTION FIVE)
+3 Tag Uses
3.1 Action Class Code
3.2 Mulitiple Image Tags
3.3 Link Tags
@@ -13,15 +25,21 @@
3.7 struts-config.xml Uses
3.7.1 MappingDispatchAction
3.7.2 LookupDispatchAction
-4 SOLUTION ONE: DispatchUtil Code
+4 SOLUTION ONE: DispatchUtil Code -------------------- SOLUTION ONE
5 (new) DispatchAction
5.1 Discussion
-5.2 SOLUTION TWO: (new) DispatchAction Code
+5.2 SOLUTION TWO: (new) DispatchAction Code ------------ SOLUTION TWO
6 POJO: Solution for Tags without Dispatch, without Reflection, without
ActionMapping or Even without Struts
6.1 Discussion
-6.2 SOLUTION THREE: ButtonTagUtil Code
-7 Links
-8 Comments (Peanut Gallery)
+6.2 SOLUTION THREE: ButtonTagUtil Code ----------------- SOLUTION THREE
+7. ButtonForm
+7.1 Discussion
+7.2 SOLUTION FOUR: ButtonForm Code --------------------- SOLUTION FOUR
+8. Button
+8.1 Discussion
+8.2 SOLUTION FIVE: Button Code ------------------------- SOLUTION FIVE
+9 Links
+10 Comments (Peanut Gallery)
}}}
@@ -451,8 +469,58 @@
}
}}}
+== ButtonForm ==
+Note that this solution does not use ".dispatch" and is not tied to Struts
+{{{
+<input type='image' name='update' src='update.gif'>
+<input type='image' name='delete' src='delete.gif'>
+}}}
+=== Discussion ===
+This solution is for <input type='image'> only. The other cases, of course, do not
pose special problems with determining which button was clicked. This solution is
superior to the Button solution which follows because only one button object has to be
created. If you use buttons for navigation extensively within large forms, this
because crucial.
+=== SOLUTION FOUR: ButtonForm Code ===
+{{{
+public class ButtonForm
+ extends ActionForm {
+ protected CrackWillowButton button;
+ protected String command;
+
+ public CrackWillowButton getButton() {
+ if(button == null) { this.button = new CrackWillowButton(); }
+ return button;
+ }
+
+ public String getCommand() {
+ String hold = command; command = null;
+ return hold;
+ }
+
+ public void reset() {
+ button = null;
+ }
+
+ public class CrackWillowButton {
+ private Integer x, y;
+ public CrackWillowButton() { }
+ public CrackWillowButton getSubmit() { command = "submit"; return button; }
+ public CrackWillowButton getClear() { command = "clear"; return button; }
+
+ public void setX(Integer x) {
+ if(y != null) { reset(); }
+ else { this.x = x; }
+ }
+
+ public void setY(Integer y) {
+ if(x != null) { reset(); }
+ else { this.y = y; }
+ }
+ }
+} ///;-)
+}}}
+== Button ==
+=== Discussion ===
+=== SOLUTION FIVE: Button Code ===
-=== Links ===
+== Links ==
StrutsCatalogMultipleImageTagsSimplified
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]