struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giuseppe Galli <>
Subject Re: Image buttons in Struts
Date Wed, 19 Jul 2000 12:12:41 GMT
Hi Alec,

Alec Bau wrote:

> Giuseppe,
> >1) find a field named 'x' in the object
> >2) if you find assign it the value passed by the request
> It's quite normal to have 2 or more image buttons within a form, i.e. Yes, No and Cancel.
So having a
> single "x" and "y" methods isn't enough since I want to distinguish action by button's

Sorry, I should have been more clear.
when I talk about the object containing the field named 'x' I was not talking about the bean,
but the
field on which the setter method set<Name>)( ) will work.
If you have a form with more than one image button, say 'Confirm' and 'Delete' that produce
a request that
can contain the following parameters: confirm, confirm.x, confirm.y OR (not AND!) delete,
delete.y, all you need is a java class that has 2 fields named 'confirm' and 'delete' whose
type is a
class that defines 2 fields: x and y.
At process time the actual values of the request parameters will be assigned to the fields
through the one
to one naming mechanism (and introspection).

> As
> opposed to image maps, for image buttons in most cases you even don't need to know button
> coordinates. That's why ideally it would be nice that Struts could handle them as normal
buttons, so
> that your controller won't depend upon what buttons were used. This way Struts can simply
map both
> name.x and name.y to "setName(String val)". Value is irrelevant here (just to conform
to JavaBeans)
> since you're interested in what particular button caused form submit. The setter could
be called twice
> (for name.x and name.y) or, preferably, BeanUtils.populate can simply skip the 2nd "name."

So all you want is to find the way that permits to struts to handle image button clicks as
normal submit
input type, since normally we are not interested in the x and y values. Uhm.. I think there
is no clean
way using setter methods, I mean that BeanUtils.populate should replace '.' with '_' or something
(obtaining 'name.x' in 'name_x') and then use the setter method set<Name>_x

...any cue?


> Thanks,
>     Alec
> Giuseppe Galli wrote:
> > hi Alec,
> > thank's to you.
> >


View raw message