String button = null; Enumeration enum = request.getParameterNames(); String parameterName = null; while(enum.hasMoreElements()) { parameterName = (String)enum.nextElement(); if(parameterName.endsWith(".x")) { button = parameterName.substring(0,parameterName.indexOf('.')); }
}
Isn't that a great deal simpler? If you want to solve it with a class, then do somethin like:
*public class ImageTagUtil { public static String getName(HttpServletRequest request) { String command = null; String buttonValue = null; Enumeration enum = request.getParameterNames();
while(enum.hasMoreElements()) { buttonValue = (String)enum.nextElement(); if(buttonValue.endsWith(".x")) { command = buttonValue.substring(0,buttonValue.indexOf('.')); } } return command; } }*
However, if you love the complications, essentially the idea is to put the paramter value together with method names in order to map the buttons to methods. So, if you have buttons returning button.add and button.delete, your parameter value will be "button". Once you know that the parameter is button, then you can search for button.? and ? will be the method name. This is a totally unnecessary complication, since we already have .x and .y at the end so generously supplied by the standard HTML. So the above code does the same thing without tying the solution to the parameter value, which frees the parameter value for other uses and which decouples the solution from struts.
Regards,
Michael
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]