tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Isaacs <Larry.Isa...@sas.com>
Subject RE: DO NOT REPLY [Bug 46293] New: Bean property getter not found when using EL expression
Date Wed, 26 Nov 2008 16:54:46 GMT
It has been a long time, but I believe the bean property naming convention is that if the second
letter is capitalized, the first letter should be capitalized too, avoiding property names
like "uRL".  If you really want "xKey", you can provide a MyBeanBeanInfo class to go with
MyBean to specify what you want.  For more details, see the JavaBeans API.

Cheers,
Larry

-----Original Message-----
From: Karl R. San Gabriel [mailto:karl.sangabriel@gmail.com]
Sent: Wednesday, November 26, 2008 10:13 AM
To: Tomcat Developers List
Subject: Re: DO NOT REPLY [Bug 46293] New: Bean property getter not found when using EL expression

bugzilla@apache.org wrote:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=46293
>
>            Summary: Bean property getter not found when using EL expression
>            Product: Tomcat 6
>            Version: 6.0.18
>           Platform: PC
>         OS/Version: Windows Vista
>             Status: NEW
>           Severity: regression
>           Priority: P2
>          Component: Jasper
>         AssignedTo: dev@tomcat.apache.org
>         ReportedBy: kuehn@mediaworx.com
>
>
> The EL expression ${myBean.xKey} does not yield a call to myBean.getXKey().
> However, ${myBean.XKey} does.
>
>
>
Dear All,

I was investigating this bug last night (Philippine time) and found out
something interesting which left me bewildered.
I was trying to come up with a proposed fix. :-)

I have the ff files:

    a) testpckg.MyBean.java

        package testpckg;
        public class MyBean {
            private String xKey = "xKey in the house";
            private String name = "name in the house";

            public String getXKey() { return xKey;}
            public String getName() { return name; }
            public void setXKey(String xKey) { this.xKey = xKey;}
            public void setName(String name) { this.name = name;}
        }

    b) index.jsp

       <jsp:useBean id="test" class="testpckg.MyBean"/>
       ${test.xKey}


In javax.el.BeanELResolver.java, BeanInfo.getPropertyDescriptors() is
giving the ff:

    pds[0].getName(): XKey
    pds[1].getName(): class
    pds[2].getName(): name


That BeanInfo.getPropertyDescriptors() call is in :

        protected final static class BeanProperties {
        private final Map<String, BeanProperty> properties;

        private final Class<?> type;

        public BeanProperties(Class<?> type) throws ELException {
            this.type = type;
            this.properties = new HashMap<String, BeanProperty>();
            try {
                BeanInfo info = Introspector.getBeanInfo(this.type);
                PropertyDescriptor[] pds = info.getPropertyDescriptors();
                for (int i = 0; i < pds.length; i++) {
                    this.properties.put(pds[i].getName(), new BeanProperty(
                            type, pds[i]));
                }
            } catch (IntrospectionException ie) {
                throw new ELException(ie);
            }
        }


It looks like Java is taking XKey from getXKey().
I could make the code convert the first character of the property to
lowercase but I not sure about that.

My settings:
    TC6.0.18
    Java 1.5

Regards,
Karl



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message