Re: s2 image submit button and methods

2006-11-30 Thread Don Brown

Thanks for bringing this up.  I created a ticket and have fixed the
issue: http://issues.apache.org/struts/browse/WW-1532

The problem is complicated by the fact that IE doesn't submit the
button name in addition to the .x and .y.  All cases should be
properly handled now.

Don

On 11/28/06, Ing. Andrea Vettori <[EMAIL PROTECTED]> wrote:

Hi,

yesterday it took me a day to understand and resolve a problem so I
think it can be useful to share it; maybe someone can explain a
better solution.

I have a form with more than one submit button. The submit buttons
are images so I used the 
tag on all but the "default" button.

The problem is that since the image button is considered by the
browser similar to an "imagemap", if the button is called btnA, the
browser submits btnA, btnA.x and btnA.y request parameters, where
the .x and .y are the coordinates of the click inside the image. I
think this cannot be disabled on the browser since it is required by
the HTML specifications.

Now this cause problems when the parameters are used by the action to
call the appropriate method. If I have a button like




in the HTML you get something like



and when the request is submitted the browser sends method:aMethod,
method:aMethod.x and method:aMethod.y parameters. This cause the
framework to try to execute the aMethod.x() method on the action
class which generate an Exception !!!

I've tried to filter the parameters with ParameterNameAware but the
parameter that starts with method: are not passed to the
acceptableParameter method. So I extended the parameters interceptor
and overrided the acceptableParameter function and even if now I see
the parameters on the method, even if I reject them, the framework
use them to try to execute the method in the action.

The solution I used is to have the image submit to set a value (like
 and use that
value inside the execute method of the action to call the appropriate
method.

But I'm looking for a better solution. I also think that since this
will be a common problem, it should be addressed by the framework
automatically rejecting method:xxx and action:xxx parameters that
ends with a ".x" and ".y".

Thanks

--
Ing. Andrea Vettori
Consulente per l'Information Technology







-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



s2 image submit button and methods

2006-11-28 Thread Ing. Andrea Vettori

Hi,

yesterday it took me a day to understand and resolve a problem so I  
think it can be useful to share it; maybe someone can explain a  
better solution.


I have a form with more than one submit button. The submit buttons  
are images so I used the   
tag on all but the "default" button.


The problem is that since the image button is considered by the  
browser similar to an "imagemap", if the button is called btnA, the  
browser submits btnA, btnA.x and btnA.y request parameters, where  
the .x and .y are the coordinates of the click inside the image. I  
think this cannot be disabled on the browser since it is required by  
the HTML specifications.


Now this cause problems when the parameters are used by the action to  
call the appropriate method. If I have a button like





in the HTML you get something like



and when the request is submitted the browser sends method:aMethod,  
method:aMethod.x and method:aMethod.y parameters. This cause the  
framework to try to execute the aMethod.x() method on the action  
class which generate an Exception !!!


I've tried to filter the parameters with ParameterNameAware but the  
parameter that starts with method: are not passed to the  
acceptableParameter method. So I extended the parameters interceptor  
and overrided the acceptableParameter function and even if now I see  
the parameters on the method, even if I reject them, the framework  
use them to try to execute the method in the action.


The solution I used is to have the image submit to set a value (like  
 and use that  
value inside the execute method of the action to call the appropriate  
method.


But I'm looking for a better solution. I also think that since this  
will be a common problem, it should be addressed by the framework  
automatically rejecting method:xxx and action:xxx parameters that  
ends with a ".x" and ".y".


Thanks

--
Ing. Andrea Vettori
Consulente per l'Information Technology