Tapestry 5
  1. Tapestry 5
  2. TAP5-921

Properties defined in an Interface are not exposed by PropertyAccess for abstract classes that do not directly implement the methods

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0.5
    • Fix Version/s: 5.2.2
    • Component/s: tapestry-ioc
    • Labels:
      None

      Description

      Here is a simple example:

      public interface HasName

      { String getName(); }

      public abstract class AbstractBean implements HasName {
      }

      public class TestPage {

      @Property
      private AbstractBean bean;

      public void onActivate() {
      bean = new AbstractBean() {
      public void setName(String name) {
      }
      };
      }
      }

      TestPage.tml
      ...
      <h1>$

      {bean.name}

      </h1>
      ...

      Error message is:

      Exception assembling root component of page manager/tools/TestPage: Could not convert 'bean.name' into a component parameter binding: Class smarter.ecommerce.smeco.manager.pages.tools.AbstractBean does not contain a property named 'name' (within property expression 'bean.name'). Available properties: class, componentResources.

      Everything works fine if I change the bean class to:

      public abstract class AbstractBean implements HasName

      { public abstract String getName(); }

        Activity

        Hide
        Igor Drobiazko added a comment -

        Tapestry asks java.beans.Introspector to determine the properties of a JavaBean. In your case the returned BeanInfo just doesn't contain any PropertyDescriptor.

        Show
        Igor Drobiazko added a comment - Tapestry asks java.beans.Introspector to determine the properties of a JavaBean. In your case the returned BeanInfo just doesn't contain any PropertyDescriptor.
        Hide
        Peter Rietzler added a comment -

        java.beans.Introspector is there for a very long time and is not very good at introspecting things, e.g. it does neither look into interfaces, nor does it include interface hierarchies. We experienced the hell a lot of problems with it, especially when you look at the static type (which may be an abstract or interface type). Since you have to look at the static type, I think the introspection must be done using the following steps:

        1) Get all properties of the static type
        2) Inspect all implemented interfaces (including those from the hierarchy) and add properties that have not been added already before
        3) Inspect all superinterfaces of all implemented interfaces and add properties that have not been added already before

        I think adding this behavior should be low risk since it will only add additional properties to the current set of properties.

        Show
        Peter Rietzler added a comment - java.beans.Introspector is there for a very long time and is not very good at introspecting things, e.g. it does neither look into interfaces, nor does it include interface hierarchies. We experienced the hell a lot of problems with it, especially when you look at the static type (which may be an abstract or interface type). Since you have to look at the static type, I think the introspection must be done using the following steps: 1) Get all properties of the static type 2) Inspect all implemented interfaces (including those from the hierarchy) and add properties that have not been added already before 3) Inspect all superinterfaces of all implemented interfaces and add properties that have not been added already before I think adding this behavior should be low risk since it will only add additional properties to the current set of properties.
        Hide
        Josh Canfield added a comment -

        Updated PropertyAccess to explicitly search interfaces when creating property adapters for abstract classes.

        Show
        Josh Canfield added a comment - Updated PropertyAccess to explicitly search interfaces when creating property adapters for abstract classes.
        Hide
        Hudson added a comment -

        Integrated in tapestry-5.2-freestyle #210 (See https://hudson.apache.org/hudson/job/tapestry-5.2-freestyle/210/)
        TAP5-921: Explicitly search interfaces when creating property adapters for abstract classes.

        Show
        Hudson added a comment - Integrated in tapestry-5.2-freestyle #210 (See https://hudson.apache.org/hudson/job/tapestry-5.2-freestyle/210/ ) TAP5-921 : Explicitly search interfaces when creating property adapters for abstract classes.

          People

          • Assignee:
            Josh Canfield
            Reporter:
            Peter Rietzler
          • Votes:
            4 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development