On Wed, 20 Nov 2002, James Higginbotham wrote:
> Date: Wed, 20 Nov 2002 13:07:23 -0600
> From: James Higginbotham <[EMAIL PROTECTED]>
> Reply-To: Jakarta Commons Users List <[EMAIL PROTECTED]>
> To: Jakarta Commons Users List <[EMAIL PROTECTED]>
> Subject: RE: [BeanUtils] Image Button Bug (was: Reflection exceptions)
>
> Thanks for the assist and pointing out a goofy bug.. I noticed Craig
> wasn't active in the last 24 hours at least,
At least not active here - ApacheCon is in Las Vegas, after all :-)
> so figured that was the
> case.
>
Just finished giving my last session, so I should have time to do a little
hacking and investingation.
> Some more info:
>
> 1. I added a block to check to see if a nested field was "y" or "x" to
> skip image tags.. That got me further
> 2. Then I started seeing that same IllegalAccessException on non-nested
> field names..
> 3. I then removed the doPriviledged() call inside the
> MappedPropertyDescriptor class and all is well - no exception, code
> works now..
> 4. I then removed the check for the "y" and "x" and all is still
> working, so it wasn't the image button at all - just the security
> check..
>
I think there's a message thread in STRUTS-USER archives that talks about
a general solution to this issue. The basic problem is that the browser,
as you point out, appends ".x" and ".y" to the field name -- and this
confuses the parser for the BeanUtils.populate() call, which assumes that
this is a nested reference.
IIRC, the solution was to define a simple separate bean for the X/Y
coordinates -- something like this:
public class MyFormBean extends ActionForm {
... the usual set of property getters/settesr ...
private SubmitBean submit = new SubmitBean();
public SubmitBean getSubmit() {
return (submit);
}
}
public class SubmitBean {
String x;
public String getX() { return (x); }
public void setX(String x) { this.x = x; };
String y;
public String getY() { return (y); }
public void setY(String y) { this.y = y; };
}
The basic idea is to turn what looks like a nested reference to "submit.x"
or "submit.y" into *real* nested references, so that the populate() method
will work correctly.
> More context info:
>
> I'm running on Windows XP with JDK 1.3.0 with Jboss 3.0.4 and Jetty
> 4.1.3. I have no server.policy configured (i.e. the server is wide open
> for now). I tried a policy, but same problem persisted. I saw a post
> about this on the commons mail archive regarding reflection and anon
> inner classes. It referenced a bug in the VM. As such, I'm not sure why
> this is showing up for me but apparently others are using the Struts
> nightly and not seeing any problems.
>
> So, I'll run with this version of beanutils for now and wait for Craig
> and/or others to provide more insight into why this is happening and
> what the overall fix should be. On to fixing a javascript validator NPE
> I was seeing (server side works) and all should be well.
>
> Thanks again,
> James
Craig
>
> > -----Original Message-----
> > From: robert burrell donkin
> > [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, November 20, 2002 12:46 PM
> > To: Jakarta Commons Users List
> > Subject: Re: [BeanUtils] Image Button Bug (was: Reflection exceptions)
> >
> >
> > On Wednesday, November 20, 2002, at 04:25 PM, James
> > Higginbotham wrote:
> >
> > > So, having narrowed this down more since my last post, I've
> > found that
> > > the BeanUtils.setProperty() method is doing a check to see
> > if there is
> > > a nested property that needs to be set. Since we are using image
> > > buttons, the name of the form element becomes GoToStep2.y, which
> > > confuses the util and makes it try a mapped property approach. I
> > > noticed an archive posting from 7/2000 that Craig mentions that it
> > > could be a bug and a fix was going to be in the works (?):
> >
> > craig and scott are at ApacheCon so you'll probably have to
> > make do with
> > me :)
> >
> > i'm not a structs expert but i'll do my best.
> >
> > <snip>
> >
> > looking through your class there was only one thing that was
> > obviously
> > wrong:
> >
> > >> public String getUuidx(){
> > >> return uuidx;
> > >> }
> > >> public void setUuidx(){
> > >> this.uuidx = uuidx;
> > >> }
> >
> > this setter is obviously buggy,
> >
> > i don't know whether this is the cause of the problem but i
> > thought that i
> > might was well point it out.
> >
> > anyway, i'll carry on with my digging.
> >
> > - robert
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:commons-user-> [EMAIL PROTECTED]>
> > For
> > additional commands,
> > e-mail: <mailto:[EMAIL PROTECTED]>
> >
> >
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>