if("submit".equals(ButtonCommand.getCommand(request))) { else if ("delete".equals(ButtonCommand.getCommand(request))) { } etc.
Right?
Michael
At 08:09 PM 8/10/2004, you wrote:
Hi Michael, please correct me if i'm wrong, but none of those solutions would work nicely in my case.
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...
> At 12:55 PM 8/10/2004, you wrote: > >Hi, this is a big question, so probably for only > the > >patient ones... > > > All the solutions with the image tag are based on > transforming the > parameter name in the tag to a value. The > name\value pair, e.g. > button.submit.x=9, is useful only for the name, i.e. > for "button.submit.x" > and not for the value, i.e. "9". This is, of > course, unusual. So, > solutions must efficiently determine whether the > name was this or that and > have no interest at all in the value in this case. > I like, after much > experimentation, just doing it as follows: > > 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; > } > } > > This works when the name attribute in <input > type='image' name='whatever> > (the property attribute in <html:image>) is whatever > you want as the > "command". (The word "command" is probably a > misnomer here.) So, if you > have <html:image property='submit'> etc., this will > be sent as something > like submit.x=7&submit.y=11. You can use the > presence of the ".x" to mine > the value of the name or property attribute directly > wherever you do your > controller logic. > > > There are two solutions at: > http://wiki.apache.org/struts/StrutsCatalogMultipleImageButtonsWithNoJavaScript. > > The one is very simple and probably is the best. > Ted Husted's solution, I > have come to think, after having done something > similar, is just to > heavy. There is no need to create all those button > objects. However, if > you read the above link and in particular the least > favored solution using > CrackWillowButton as an inner class for ActionForms, > you will see how Ted's > works, I think, since the ideas are similar. > > > >
===== _________________________________ Leandro Terra C. Melo Eng. de Controle e Automação - UFMG
_______________________________________________________
Yahoo! Acesso Grátis - navegue de graça com conexão de qualidade! Acesse: http://br.acesso.yahoo.com/
--------------------------------------------------------------------- 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]