You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2008/11/25 17:07:11 UTC

DO NOT REPLY [Bug 46293] New: Bean property getter not found when using EL expression

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.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 46293] Bean property getter not found when using EL expression

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46293


Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #1 from Mark Thomas <ma...@apache.org>  2008-11-27 11:25:42 PST ---
The bean is not consistent with the bean spec (section 8.8).


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


RE: DO NOT REPLY [Bug 46293] New: Bean property getter not found when using EL expression

Posted by Larry Isaacs <La...@sas.com>.
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



Re: DO NOT REPLY [Bug 46293] New: Bean property getter not found when using EL expression

Posted by "Karl R. San Gabriel" <ka...@gmail.com>.
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


DO NOT REPLY [Bug 46293] Bean property getter not found when using EL expression

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46293


Dennis <ku...@mediaworx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kuehn@mediaworx.com




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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