Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > bean reflection oddity

Reply
Thread Tools

bean reflection oddity

 
 
nooobody
Guest
Posts: n/a
 
      02-20-2005
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




 
Reply With Quote
 
 
 
 
Stefan Schulz
Guest
Posts: n/a
 
      02-20-2005
On Sun, 20 Feb 2005 06:32:29 +0000, nooobody wrote:

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


Call the property "IPod".

--
In pioneer days they used oxen for heavy pulling, and when one ox
couldn't budge a log, they didn't try to grow a larger ox. We shouldn't
be trying for bigger computers, but for more systems of computers.
--- Rear Admiral Grace Murray Hopper

 
Reply With Quote
 
 
 
 
Wendy S
Guest
Posts: n/a
 
      02-20-2005
"nooobody" <(E-Mail Removed)> wrote
> 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."

--
Wendy


 
Reply With Quote
 
nooobody
Guest
Posts: n/a
 
      02-20-2005
Wendy S wrote:
> "nooobody" <(E-Mail Removed)> wrote
>> 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."



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.


 
Reply With Quote
 
nooobody
Guest
Posts: n/a
 
      02-20-2005

>"nooobody" wrote
>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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP] Bean Newbie: C++ library to Java bean. How? Takeshi Java 0 01-28-2004 11:36 AM
Differnce between Java Bean and Enterprise Java Bean Markku Salminen Java 3 01-21-2004 09:25 AM
Commentss required for reflection bean copying util class Ben Jessel Java 2 09-16-2003 11:11 AM
can a session bean return a local entity bean object? David Thielen Java 2 09-12-2003 07:45 AM
To bean or not to bean... Benjamin Stewart Java 0 06-30-2003 12:34 AM



Advertisments