PLEASE TAKE ME OFF THIS MAILING -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 18, 2004 1:21 PM To: [EMAIL PROTECTED] Subject: [Apache Struts Wiki] Updated: StrutsCatalogMultipleImageTagsSimplified
Date: 2004-08-18T10:21:14 Editor: MichaelMcGrady <[EMAIL PROTECTED]> Wiki: Apache Struts Wiki Page: StrutsCatalogMultipleImageTagsSimplified URL: http://wiki.apache.org/struts/StrutsCatalogMultipleImageTagsSimplified no comment Change Log: ---------------------------------------------------------------------------- -- @@ -32,13 +32,8 @@ '''There you go. I suggest that you toss out the !LookupDispatchActions, the !ButtonCommands, etc. This is a done deal. You can clearly seek other ways to ensure a bit more safety. For example, the code works equally as well with "submit.button" as it does with "submit". Elegant, no, eh? I use a class that encapsulates this functionality as follows: {{{ -package com.crackwillow.struts.util.button; - -import java.util.Enumeration; -import javax.servlet.http.HttpServletRequest; - -public class ButtonValue { - public static String getValue(HttpServletRequest request) { +public class ImageTagUtil { + public static String getName(HttpServletRequest request) { String command = null; String buttonValue = null; Enumeration enum = request.getParameterNames(); @@ -49,13 +44,13 @@ command = buttonValue.substring(0,buttonValue.indexOf('.')); } } - return command; } } }}} -Surprisingly, some people still prefer the way I used to do this. I think they just like the plain fanciness of it all. For those people, here is code that is less extensible, more coupled, heavier, etc. This code is comparatively horrible, in my opinion, but it looks so "codey". +Surprisingly, some people still prefer the way I used to do this. I think they just like the plain fanciness of it all. For those people, here is code that is less extensible, more coupled, heavier, etc. This code is comparatively not as good, in my opinion. There is a further use of button objects which requires that you create a separate button object for each image button you use on an html page. That solution is very heavy and significantly affects the footprint of a struts page. ''If'' you are going to use buttons, ''which, again, is not recommended'', I would suggest the following more lightweight version, which creates and then nulls one button object per request. The use of an inner class allows the necessary communications between the action form and the button class. + {{{ public class AdminButtonForm extends ActionForm { @@ -137,6 +132,8 @@ } } }}} +So, don't use buttons, but just mine the value of the [name].x request parameter. + Michael !McGrady Cap't of the Eh Team''' --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
