bean reflection oddity

N

nooobody

I've seen information on this previously but can't track it down at
the moment. I've noticed the problem while trying out some reflection
in a Struts application.

in my jsp I have: <bean:write name="theFormBean" property="iPod"/>

in my form bean I have the getter: public String getIPod() { return
iPod; }, which was generated by JDeveloper.

When I run the application I get the error: No getter method for
property iPod of bean theFormBean. When I change the method name to
getiPod() it works correctly.

I want to call a getter in the form bean; which one will depend on
which radio button is selected. I am building the getter method name
out of the value of the radio button, and don't want to be
constrained on what values I give the radio buttons. Does anyone know
where I can get further information on this?


Tim B
 
W

Wendy S

nooobody said:
I've seen information on this previously but can't track it down at
the moment. I've noticed the problem while trying out some reflection
in a Struts application.
in my jsp I have: <bean:write name="theFormBean" property="iPod"/>
in my form bean I have the getter: public String getIPod() { return
iPod; }, which was generated by JDeveloper.

The JavaBeans specification:
http://java.sun.com/products/javabeans/docs/spec.html

8.8 Captialization of inferred names
"Thus when we extract a property or event name from the middle of an
existing Java name, we
normally convert the first character to lower case. However to support the
occasional use of all
upper-case names, we check if the first two characters of the name are both
upper case and if
so leave it alone."
 
N

nooobody

Wendy said:
The JavaBeans specification:
http://java.sun.com/products/javabeans/docs/spec.html

8.8 Captialization of inferred names
"Thus when we extract a property or event name from the middle of an
existing Java name, we
normally convert the first character to lower case. However to
support the occasional use of all
upper-case names, we check if the first two characters of the name
are both upper case and if
so leave it alone."


Thanks, Wendy. I found the "decapitalize" method in the Introspector
class, which implements the specification you cited. That sheds some
light, but what would be nice would be to find the class and method
used to translate "iPod" to "getiPod", "foo" to getFoo" and "a" to
"getA" , etc., rather than writing my own.
 
N

nooobody

what would be nice would be to find the class and method
used to translate "iPod" to "getiPod", "foo" to getFoo" and "a" to
"getA" , etc., rather than writing my own.

looks like I found what I was looking for, in the PropertyDescriptor
class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top