You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jon Ferguson <ca...@btinternet.com> on 2002/03/12 23:24:26 UTC

Re: No getter - method order bug?

Hey guys,

I've finally managed to get this to work.. I thought it would be a classpath
prob.. but looks a bit more insidious.  In my CategoryWrapper class I
actually
had three relevant methods:
public void setMapping(int index)
public void setMapping(Map)
public Map getMapping()

The first is only used for setting things up explicitly...  However because
it came before the others struts expects there to be a
public int getMapping() method.  Even though the one requred for the jsp is
available.  If I move "Map getMapping()" above the other
two in my source code this works.  Java does not
guarrantee order when listing methods with getDeclaredMethods()
so I suspect the logic:iterate tag is not testing the methods
correctly?

Any other takes on this?  I realise I should probably change the
name of the first method to something like initializeMapping(int index)
but it doesn't seem like it should fail.. Especially since this
is likely to be random.

Cheers,
Jon

Jon Ferguson wrote:

> Hey guys, anybody see this??  I've had the particular exception before but
> it's always been apparent what it was [eg. me :-) ].
>
> I'm developing on Linux and Windows 2k.
>
> I've built a struts/tiles app that works flawlessly under my
> linux setup but when I serve it from my Windows 2k box I'm
> getting :
>
> "No getter method for property mapping of bean category"
> when my jsp is hit.  The offending code uses a <logic:iterate>
> as follows:
>
> <logic:iterate id="category"
> type="uk.co.omegasoftware.util.struts.CategoryWrapper"
>                              name="itemListForm"
> property="categoryWrappers">
>         <tr>
>           <td>
>             <html:link page="/inventory.do" name="category"
> property="mapping">
>               <bean:write name="category" property="name" filter="true"/>
>             </html:link>
>           </td>
>         </tr>
> </logic:iterate>
>
> the CategoryWrapper class Does have the appropriate accessors:
> ...
>     public void setMapping(Map map) {
>         mapping = map;
>     }
>
>    public Map getMapping() {
>       return mapping;
>    }
> ...
>
> In both cases I'm using release versions of struts. I've tried 1.0: 1.0.1
> and 1.0.2
>
> I'm running on Tomcat 4.0-b6 on my Linux box..
> I've tried: Tomcat 4.0.1, 3.2.3, and 4.0 on my Windows box.
>
> I'm using JDK 1.4.0-beta on linux
> I've tried JDK 1.3.1, 1.4.0-beta and 1.4.0-beta3 on windows
>
> Any ideas??
>
> Thanks,
>
> Jon
>
>   ------------------------------------------------------------------------
>    Part 1.2Type: Plain Text (text/plain)


Re: No getter - method order bug?

Posted by Jon Ferguson <ca...@btinternet.com>.
Keith,

I suspect its more like if you overload you must overload both get and set.. eg..
if it takes an int there should be one that returns an int?.. Actually this
all falls down when you consider properties of arrays.. you can return the
whole array or one item.. but then the pattern is to have a get which takes an
int and returns an object..

Thanks for your input.. I think I Better be more rigorous in my namint!

Jon

keithBacon wrote:

> Hi Jon,
> Good debugging! I'd like to see some clear rules about struts & bean
> properties,
> so here's my attempt. (Not having read the bean spec very carefully!).
> 1 - If you want something treated as a property you must have get & set methods
> even if you won't call them both (from bean spec).
> 2 - Declare the get & set methods together (not necessary but good standard)
> most people do get before the set.
> 3 - If you overload the methods keep the matched pairs together.
>
> This is alarmimg. I figure if if follow these rules I won't hit any problems.
> It seems you've discovered that it's dangerous to overload methods that are
> properties. Has some-one got the time to get to the bottom of this?
> cheers - Keith.
>
> --- Jon Ferguson <ca...@btinternet.com> wrote:
> > Hey guys,
> >
> > I've finally managed to get this to work.. I thought it would be a classpath
> > prob.. but looks a bit more insidious.  In my CategoryWrapper class I
> > actually
> > had three relevant methods:
> > public void setMapping(int index)
> > public void setMapping(Map)
> > public Map getMapping()
> >
> > The first is only used for setting things up explicitly...  However because
> > it came before the others struts expects there to be a
> > public int getMapping() method.  Even though the one requred for the jsp is
> > available.  If I move "Map getMapping()" above the other
> > two in my source code this works.  Java does not
> > guarrantee order when listing methods with getDeclaredMethods()
> > so I suspect the logic:iterate tag is not testing the methods
> > correctly?
> >
> > Any other takes on this?  I realise I should probably change the
> > name of the first method to something like initializeMapping(int index)
> > but it doesn't seem like it should fail.. Especially since this
> > is likely to be random.
> >
> > Cheers,
> > Jon
> >
> > Jon Ferguson wrote:
> >
> > > Hey guys, anybody see this??  I've had the particular exception before but
> > > it's always been apparent what it was [eg. me :-) ].
> > >
> > > I'm developing on Linux and Windows 2k.
> > >
> > > I've built a struts/tiles app that works flawlessly under my
> > > linux setup but when I serve it from my Windows 2k box I'm
> > > getting :
> > >
> > > "No getter method for property mapping of bean category"
> > > when my jsp is hit.  The offending code uses a <logic:iterate>
> > > as follows:
> > >
> > > <logic:iterate id="category"
> > > type="uk.co.omegasoftware.util.struts.CategoryWrapper"
> > >                              name="itemListForm"
> > > property="categoryWrappers">
> > >         <tr>
> > >           <td>
> > >             <html:link page="/inventory.do" name="category"
> > > property="mapping">
> > >               <bean:write name="category" property="name" filter="true"/>
> > >             </html:link>
> > >           </td>
> > >         </tr>
> > > </logic:iterate>
> > >
> > > the CategoryWrapper class Does have the appropriate accessors:
> > > ...
> > >     public void setMapping(Map map) {
> > >         mapping = map;
> > >     }
> > >
> > >    public Map getMapping() {
> > >       return mapping;
> > >    }
> > > ...
> > >
> > > In both cases I'm using release versions of struts. I've tried 1.0: 1.0.1
> > > and 1.0.2
> > >
> > > I'm running on Tomcat 4.0-b6 on my Linux box..
> > > I've tried: Tomcat 4.0.1, 3.2.3, and 4.0 on my Windows box.
> > >
> > > I'm using JDK 1.4.0-beta on linux
> > > I've tried JDK 1.3.1, 1.4.0-beta and 1.4.0-beta3 on windows
> > >
> > > Any ideas??
> > >
> > > Thanks,
> > >
> > > Jon
> > >
> > >   ------------------------------------------------------------------------
> > >    Part 1.2Type: Plain Text (text/plain)
> >
> > > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
>
> =====
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Search the archive:-
> http://www.mail-archive.com/struts-user%40jakarta.apache.org/
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Keith Bacon - Looking for struts work - South-East UK.
> phone UK 07960 011275
>
> __________________________________________________
> Do You Yahoo!?
> Try FREE Yahoo! Mail - the world's greatest free email!
> http://mail.yahoo.com/
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: No getter - method order bug?

Posted by keithBacon <ke...@yahoo.com>.
Hi Jon,
Good debugging! I'd like to see some clear rules about struts & bean
properties,
so here's my attempt. (Not having read the bean spec very carefully!).
1 - If you want something treated as a property you must have get & set methods
even if you won't call them both (from bean spec).
2 - Declare the get & set methods together (not necessary but good standard)
most people do get before the set. 
3 - If you overload the methods keep the matched pairs together.

This is alarmimg. I figure if if follow these rules I won't hit any problems.
It seems you've discovered that it's dangerous to overload methods that are
properties. Has some-one got the time to get to the bottom of this?
cheers - Keith.

--- Jon Ferguson <ca...@btinternet.com> wrote:
> Hey guys,
> 
> I've finally managed to get this to work.. I thought it would be a classpath
> prob.. but looks a bit more insidious.  In my CategoryWrapper class I
> actually
> had three relevant methods:
> public void setMapping(int index)
> public void setMapping(Map)
> public Map getMapping()
> 
> The first is only used for setting things up explicitly...  However because
> it came before the others struts expects there to be a
> public int getMapping() method.  Even though the one requred for the jsp is
> available.  If I move "Map getMapping()" above the other
> two in my source code this works.  Java does not
> guarrantee order when listing methods with getDeclaredMethods()
> so I suspect the logic:iterate tag is not testing the methods
> correctly?
> 
> Any other takes on this?  I realise I should probably change the
> name of the first method to something like initializeMapping(int index)
> but it doesn't seem like it should fail.. Especially since this
> is likely to be random.
> 
> Cheers,
> Jon
> 
> Jon Ferguson wrote:
> 
> > Hey guys, anybody see this??  I've had the particular exception before but
> > it's always been apparent what it was [eg. me :-) ].
> >
> > I'm developing on Linux and Windows 2k.
> >
> > I've built a struts/tiles app that works flawlessly under my
> > linux setup but when I serve it from my Windows 2k box I'm
> > getting :
> >
> > "No getter method for property mapping of bean category"
> > when my jsp is hit.  The offending code uses a <logic:iterate>
> > as follows:
> >
> > <logic:iterate id="category"
> > type="uk.co.omegasoftware.util.struts.CategoryWrapper"
> >                              name="itemListForm"
> > property="categoryWrappers">
> >         <tr>
> >           <td>
> >             <html:link page="/inventory.do" name="category"
> > property="mapping">
> >               <bean:write name="category" property="name" filter="true"/>
> >             </html:link>
> >           </td>
> >         </tr>
> > </logic:iterate>
> >
> > the CategoryWrapper class Does have the appropriate accessors:
> > ...
> >     public void setMapping(Map map) {
> >         mapping = map;
> >     }
> >
> >    public Map getMapping() {
> >       return mapping;
> >    }
> > ...
> >
> > In both cases I'm using release versions of struts. I've tried 1.0: 1.0.1
> > and 1.0.2
> >
> > I'm running on Tomcat 4.0-b6 on my Linux box..
> > I've tried: Tomcat 4.0.1, 3.2.3, and 4.0 on my Windows box.
> >
> > I'm using JDK 1.4.0-beta on linux
> > I've tried JDK 1.3.1, 1.4.0-beta and 1.4.0-beta3 on windows
> >
> > Any ideas??
> >
> > Thanks,
> >
> > Jon
> >
> >   ------------------------------------------------------------------------
> >    Part 1.2Type: Plain Text (text/plain)
> 
> > --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


=====
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Search the archive:-
http://www.mail-archive.com/struts-user%40jakarta.apache.org/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Keith Bacon - Looking for struts work - South-East UK.
phone UK 07960 011275

__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>