You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Yao, Guang" <Gu...@teamtki.com> on 2001/03/16 23:52:46 UTC

HTML paramter and its getter name

Hi,

I have the following parameter defined in a JSP page using <html:hidden>
tag:

<html:hidden property="CompanyID"/>

In its correpsonding ActionForm class, there is a getter for it which name
is "getCompanyID()".

However, Struts can not find this getter:
javax.servlet.ServletException: No getter method for property CompanyID of
bean org.apache.struts.taglib.html.BEAN
If I change "CompanyID" to "companyID", then problem is fixed. Can anybody
tell me why? What is the right getter name for a parameter which starts with
upper case letter?
Thanks,
- Guang



Re: HTML paramter and its getter name

Posted by Ken Beyer <ka...@metatec.com>.
That is correct behavior.  You MUST use property="companyID"
and the getter method for it would be "getCompanyID()"

As I just recently found out :-) you should use a capital letter
*only* when followed by another capital letter.  For example, if you
had a "getAAA()" defined in your JavaBean, you'd use property="AAA",
but if you had "getAaA()", you'd use property="aaA".

Ken

"Yao, Guang" wrote:

> Hi,
>
> I have the following parameter defined in a JSP page using <html:hidden>
> tag:
>
> <html:hidden property="CompanyID"/>
>
> In its correpsonding ActionForm class, there is a getter for it which name
> is "getCompanyID()".
>
> However, Struts can not find this getter:
> javax.servlet.ServletException: No getter method for property CompanyID of
> bean org.apache.struts.taglib.html.BEAN
> If I change "CompanyID" to "companyID", then problem is fixed. Can anybody
> tell me why? What is the right getter name for a parameter which starts with
> upper case letter?
> Thanks,
> - Guang

--
Ken Beyer
Metatec Internet Products Group
kab@metatec.com  |  http://www.metatec.com/
"The box said 'Requires Windows 95 or better.' - so I installed Linux."