bean reflection oddity

Discussion in 'Java' started by nooobody, Feb 20, 2005.

  1. nooobody

    nooobody Guest

    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
     
    nooobody, Feb 20, 2005
    #1
    1. Advertising

  2. 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
     
    Stefan Schulz, Feb 20, 2005
    #2
    1. Advertising

  3. nooobody

    Wendy S Guest

    "nooobody" <> 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
     
    Wendy S, Feb 20, 2005
    #3
  4. nooobody

    nooobody Guest

    Wendy S wrote:
    > "nooobody" <> 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.
     
    nooobody, Feb 20, 2005
    #4
  5. nooobody

    nooobody Guest


    >"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
     
    nooobody, Feb 20, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin Stewart

    To bean or not to bean...

    Benjamin Stewart, Jun 30, 2003, in forum: Java
    Replies:
    0
    Views:
    828
    Benjamin Stewart
    Jun 30, 2003
  2. Ben Jessel
    Replies:
    2
    Views:
    529
    Ben Jessel
    Sep 16, 2003
  3. David Thielen
    Replies:
    2
    Views:
    834
    Marek Lange
    Sep 12, 2003
  4. Markku Salminen
    Replies:
    3
    Views:
    5,891
    Michael Borgwardt
    Jan 21, 2004
  5. Takeshi
    Replies:
    0
    Views:
    546
    Takeshi
    Jan 28, 2004
Loading...

Share This Page