The good news is that this DOES work.

I simply declared my methods to be

public void setFoo(String key, String[] foos)
{
...
}

public String[] getFoo(String key)
{
...
}

and everything works fine. It took a detour through the Struts
source (and ultimately from there through the beanutils source)
to figure this out, but the problem was essentially that when
doing the bean introspection, the beanutils first finds the getFoo()
method and stores its return type. It then looks for a setFoo()
method with the same argument type as the return type of getFoo().
If you try to return foo as an Object, it just won't work -- your
setter won't be found and the method will never be called.

thanks for the input,

Mike


> -----Original Message-----
> From: Radu Badita [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 07, 2005 11:10 AM
> To: Struts Users Mailing List
> Subject: RE: map-backed forms with multibox/multiselect lists?
> 
> 
> 
> I had the same problem some time ago (the solution vaguely 
> suggested by 
> Jack wouldn't had been an option since the properties were 
> dynamic so I 
> needed the key to distinguish between them). I asked on this 
> list for help 
> at that time, but didn't got an answer, so I guess nobody 
> succeeded in 
> doing something like this. Therefore I had to find some other 
> solution to 
> my problem...
> I'm guessing this might be some sort of a problem with 
> commons-binutils 
> (although public void setFoos(String key, String[] foos) 
> isn't a valid 
> javabeans setter so maybe it's just a bit out of it's scope).
> 
> At 16:44 07.03.2005, you wrote:
> >This works fine for list-backed form items (which we also use)
> >but in this case I need something like
> >
> >public void setFoos(String key, String[] foos)
> >
> >is this possible?
> >
> >
> >There are several workarounds I can think of, but this appears
> >to be the cleanest solution if I can make it work.
> >
> >Mike
> >
> > > -----Original Message-----
> > > From: Dakota Jack [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, March 07, 2005 9:42 AM
> > > To: Struts Users Mailing List
> > > Subject: Re: map-backed forms with multibox/multiselect lists?
> > >
> > >
> > > public void setFoos(String [] foos)
> > >
> > >
> > > On Fri, 4 Mar 2005 18:55:53 +0000 (UTC), Mike Nidel
> > > <[EMAIL PROTECTED]> wrote:
> > > > I'm trying to build a form element that combines the
> > > features of a map-backed
> > > > property with a multibox (and the same for a
> > > multiple-selection list). I've made
> > > > multiboxes work fine without the map-backed element, but I
> > > can't seem to get
> > > > this to work.
> > > >
> > > > I've tried various method signatures in my form bean, but
> > > to no avail. For
> > > > example, for a field called "foo" I have tried the following:
> > > >
> > > > public void setFoo(String key, Object val)
> > > > {
> > > > ...
> > > > }
> > > >
> > > > or
> > > >
> > > > public void setFoo(String key, String[] val)
> > > > {
> > > > ...
> > > > }
> > > >
> > > > I'm using a set of checkboxes on the JSP which should
> > > result in a list of the
> > > > values of whichever boxes are selected. I can think of a
> > > number of javascript
> > > > workarounds, as well as workarounds in my Action that go
> > > directly to the request
> > > > parameters... but all of those are kludges and it seems
> > > like there should be a
> > > > way to have multiple checkboxes that all reference a
> > > map-backed form property.
> > > >
> > > > Any thoughts?
> > > >
> > > > thanks a bunch,
> > > >
> > > > Mike Nidel
> > > >
> > > >
> > > 
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> > > --
> > > "You can lead a horse to water but you cannot make it float
> > > on its back."
> > > ~Dakota Jack~
> > >
> > > 
> ---------------------------------------------------------------------
> > > 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]
> 
> 
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to