The whole point of using an image tag solution is to (1) get out of a Struts specific solution to this "age old" problem and to (2) provide a solution to the need to make a switch in the processing of an action. The ".x" and ".y" in the parameter names of an image tag operate just like the parameter attribute of the action mapping for the LookupDispatchAction and DispatchAction. The difference is that it is not Struts specific and is a "worldwide" standard. The code which follows, viz.
public final class ButtonCommand { private ButtonCommand() { } public final static String getCommand(HttpServletRequest request) { Enumeration enum = request.getParameterNames(); String parameterName = null; while(enum.hasMoreElements()) { parameterName = (String)enum.nextElement(); if(parameterName.endsWith(".x")) { return parameterName.substring(0,parameterName.indexOf('.')); } } return parameterName; } }
simply does this using image tags instead of hidden parameters in the form. You can, of course, just copy the method getCommand into your processing helper classes in the model.
Does this ring any bells?
Michael McGrady
At 08:09 PM 8/10/2004, you wrote:
The problem is that both solutions in a higher level focus on getting the parameter and checking it out to see its value.
In my case, i got a MyLookupDispatchAction that receives all the requests and forwards it to the specific method. So, there's no meanwhile to get the request parameter, check it out and forward to some method.
UNLESS, i use someking of hidden field in the form with a name that MyLookupDispatchAction expects:
protected Map getKeyMethodMap(){ Map map = new HashMap(); map.put("hidden.field", "verifyParameterMethod"); }
And the in the "verifyParameterMethod()", i'd use call
"getCommand(HttpServletRequest request)" to check what was the value of the real parameter i want (the one from the image tag). Finally, i would compare this value and forward the data to the responsible method. Am i correct?
It just seems a little confusing...