[EMAIL PROTECTED] 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: [email protected]
        ReportedBy: [EMAIL PROTECTED]


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to