The rule of thumb to follow is that property names should start with a lower
case letter. Otherwise you may come up with property names that cannot be
made to work with getters and setters. This is illustrated in the answers to
your questions below.
> So what IS the getter name for this property - "LastName" ?
There isn't one. If the method was called getLastName, the rules say that,
once 'get' is removed, the first letter should be converted to lower case,
so the property name is 'lastName'. The only exception to converting the
first letter to lower case is when the second letter is also upper case.
> So what IS the getter name for this property - "LASTNAME" => get???
The getter for this is getLASTNAME. Once 'get' is removed, we see that both
the first and second letters are upper case, so the name remains unchanged.
> So what IS the getter name for this property - "lastname" => get???
The getter for this is getLastname. Again, once 'get' is removed, we convert
the first letter to lower case and the property name is 'lastname'.
If you stick to property names that use the same convention as for Java
variables (i.e. the first letter is lower case, and the first letter of
subsequent words is capitalised), then you shouldn't have problems.
I hope this helps clarify.
--
Martin Cooper
----- Original Message -----
From: "Tim Colson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, July 08, 2001 6:49 AM
Subject: RE: Bean Introspection and <bean:write> tag
> Martin - et. al. -
>
> > What you are seeing is the correct behaviour.
> > Hope this helps.
>
> Thanks for the info - it certainly makes sense, but ultimately you didn't
> answer my question, just re-phrased it. ;-)
>
> "What is the getter name for this property?".
>
> So what IS the getter name for this property - "LastName" ?
>
> BTW - Bean introspection feature or not - it could be a hard sell to get
> designer folk to write "correct cased properties"... especially if they
are
> accustomed to using "LastName" and I can't seem to handle that. Makes the
> developer guy (me) appear not so smart. <grin>
>
> So what IS the getter name for this property - "LASTNAME" => get???
> So what IS the getter name for this property - "lastname" => get???
>
> Thanks! :-)
> Timothy
>
> > ----- Original Message -----
> > From: "Tim Colson" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, July 06, 2001 12:12 PM
> > Subject: Bean Introspection and <bean:write> tag
> >
> >
> > > As per the bean: struts API docs, I've included an "Employee"
> > type object
> > > into the request scope called "emp".
> > >
> > > emp can get/set the "mLastName" property using getLastName() and
> > > setLastName()
> > >
> > > However - when I try the following
> > >
> > > <bean:write name="emp" property="LastName"/>
> > >
> > > I'm told that there is no "getter" method
> > > javax.servlet.ServletException: No getter method for property
> > LastName of
> > > bean
> > >
> > > If I make the property initial lower case, it works fine:
> > > <bean:write name="emp" property="lastName"/>
> > >
> > >
> > > The Bean Spec Section 8.8 says this about capitalization:
> > > So for example, "FooBah" becomes "fooBah"
> > > ---
> > > So for example, "LastName" becomes "lastName"
> > > I tried adding the accessor "getlastName()" to my Employee class -
still
> > > fails.
> > >
> > > Property -> get method : result
> > > -------------------------------------
> > > "lastName" -> getLastName() : OK
> > > "LastName" -> getLastName() : Fails
> > > "LastName" -> getlastName() : Fails
> > > "LastName" -> get?????()
> > >
> > > I searched the archives and read more of the bean spec - but didn't
pull
> > up
> > > anything useful on this. :-(
> > >
> > > Thanks,
> > > Tim
> > >
> > >
> >
> >
> >
>
>