You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ken Pelletier <ke...@nika.com> on 2003/04/17 01:41:26 UTC

ImageButtonBean and isSelected() behavior

I have a form that contains two submit buttons, and I'm trying to use 
org.apache.struts.util.ImageButtonBean to detect which was pressed.

In the jsp, the submit buttons are created with the <html:submit> tag.

The ActionForm subclass I'm using is a DynaValidatorForm.

I'm finding that the ImageButtonBean x,y values are being explicitly 
set to "0" when when the button was not pressed.

I initially thought this may have been behavior peculiar to a 
particular browser, but this appears to be the case for as many 
browsers as I could get my grubs on.

This, of course, causes isSelected() to interpret those as button 
presses for each instance of ImageButtonBean.

I can work around it by applying a more strict meaning to isSelected() 
in a SubmitButtonBean subclass, but it strikes me that maybe the 
interpretation of isSelected() ought to consider non-"0" values in 
addition to non-null in this way to allow for it.

It does seem odd that a 0,0 value is being sent, however, since the x,y 
coord of a hit on the image could conceivably be 0,0 - assuming the 
coord system is 0-based.

- K






---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: ImageButtonBean and isSelected() behavior

Posted by Ken Pelletier <ke...@nika.com>.
Yes, I am using ImageButtonBean to sense which was pressed, not where 
on the image
button the hit was located.

The behavior of HTML forms isn't up for grabs, though; that's just the 
way an image button
press is sent - with x,y coords of the click. ImageButtonBean is a 
clever trick to interpret those
separate values and record them in the FormBean as property, which is a 
bean with two
properties, x and y.

I now realize I referred to <html:submit> below, where I meant 
<html:image>

The problem is down to the fact that, since the beans are being 
initialized with x="0", y="0"
when not pressed, ImageButtonBean's isSelected() returns true always... 
for each button.

- K

On Wednesday, April 16, 2003, at 06:55  PM, Max Cooper wrote:

> K,
>
> It sounds like that class is for server-side image maps -- doing 
> something
> different depending on where the user clicks within a single image. 
> From you
> description, it sounds like you need to figure out which of two images 
> was
> clicked, rather than where the user clicked within a single image. Your
> button images are two separate images, right?
>
> -Max
>
> ----- Original Message -----
> From: "Ken Pelletier" <ke...@nika.com>
> To: <st...@jakarta.apache.org>
> Sent: Wednesday, April 16, 2003 4:41 PM
> Subject: ImageButtonBean and isSelected() behavior
>
>
>> I have a form that contains two submit buttons, and I'm trying to use
>> org.apache.struts.util.ImageButtonBean to detect which was pressed.
>>
>> In the jsp, the submit buttons are created with the <html:submit> tag.
>>
>> The ActionForm subclass I'm using is a DynaValidatorForm.
>>
>> I'm finding that the ImageButtonBean x,y values are being explicitly
>> set to "0" when when the button was not pressed.
>>
>> I initially thought this may have been behavior peculiar to a
>> particular browser, but this appears to be the case for as many
>> browsers as I could get my grubs on.
>>
>> This, of course, causes isSelected() to interpret those as button
>> presses for each instance of ImageButtonBean.
>>
>> I can work around it by applying a more strict meaning to isSelected()
>> in a SubmitButtonBean subclass, but it strikes me that maybe the
>> interpretation of isSelected() ought to consider non-"0" values in
>> addition to non-null in this way to allow for it.
>>
>> It does seem odd that a 0,0 value is being sent, however, since the 
>> x,y
>> coord of a hit on the image could conceivably be 0,0 - assuming the
>> coord system is 0-based.
>>
>> - K
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: ImageButtonBean and isSelected() behavior

Posted by Max Cooper <ma...@maxcooper.com>.
K,

It sounds like that class is for server-side image maps -- doing something
different depending on where the user clicks within a single image. From you
description, it sounds like you need to figure out which of two images was
clicked, rather than where the user clicked within a single image. Your
button images are two separate images, right?

-Max

----- Original Message -----
From: "Ken Pelletier" <ke...@nika.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, April 16, 2003 4:41 PM
Subject: ImageButtonBean and isSelected() behavior


> I have a form that contains two submit buttons, and I'm trying to use
> org.apache.struts.util.ImageButtonBean to detect which was pressed.
>
> In the jsp, the submit buttons are created with the <html:submit> tag.
>
> The ActionForm subclass I'm using is a DynaValidatorForm.
>
> I'm finding that the ImageButtonBean x,y values are being explicitly
> set to "0" when when the button was not pressed.
>
> I initially thought this may have been behavior peculiar to a
> particular browser, but this appears to be the case for as many
> browsers as I could get my grubs on.
>
> This, of course, causes isSelected() to interpret those as button
> presses for each instance of ImageButtonBean.
>
> I can work around it by applying a more strict meaning to isSelected()
> in a SubmitButtonBean subclass, but it strikes me that maybe the
> interpretation of isSelected() ought to consider non-"0" values in
> addition to non-null in this way to allow for it.
>
> It does seem odd that a 0,0 value is being sent, however, since the x,y
> coord of a hit on the image could conceivably be 0,0 - assuming the
> coord system is 0-based.
>
> - K
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org