my dog learned polymorphism
The moose likes Servlets and the fly likes Bean properties - case convention anomaly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Bean properties - case convention anomaly" Watch "Bean properties - case convention anomaly" New topic

Bean properties - case convention anomaly

chris leonardi

Joined: Feb 25, 2001
Posts: 3
Hello -
I'm running into a really odd problem on Tomcat 3.2.1. Here goes: I've got a bean. The bean has a bunch of properties. Some of the fields look like this:
protected String aFieldName;
protected String bFieldName;
protected String cFieldName;
The corresponding accessor methods look like this:
public void setAFieldName(String v)
this.aFieldName = v;
public String getAFieldName()
return this.aFieldName;
Pretty straightforward stuff, it would seem. However, when using the standard jsp:setProperty and jsp:getProperty tags for the bean's properties, it appears the the JSP engine's introspection "breaks down" - it can't seem to locate the appropriate accessor method (throws "no get method for property 'aFieldName' found in bean ....". I get essentially the same result using Jakarta Struts tag extensions to manipulate the bean. Interestingly enough, I can access the method's directly using scriptlet code ("<% String foo = myBean.getAFieldName(); %>" ).
Now here's where it gets really bizare. Change the field names: instead of having a lower-case first position character, followed by an upper-case second position character, add in another lower-case character. So:
protected String aaFieldName;
And modify the accessor methods accordingly:
public void setAaFieldName(String v)
this.aaFieldName = v;
public String getAaFieldName()
return this.aaFieldName;
Now it works. Can anyone else reproduce this phenomenon - either on Tomcat or another JSP engine? Am I missing something? Any ideas would be much appreciated - while I'd like to simply rename the fields and put the whole issue to rest, the bean properties are being defined by a client's design documents. Thanks,
*** update ***
for anyone who's interested, it looks like this is a documented "bug" in tomcat 3.2.1:
[This message has been edited by chris leonardi (edited March 16, 2001).]
I agree. Here's the link:
subject: Bean properties - case convention anomaly
It's not a secret anymore!