Tapestry 5
  1. Tapestry 5
  2. TAP5-818

Tapestry should properly support JDK 1.5 Generics when reading and updating properties and property expressions

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0.5
    • Fix Version/s: 5.2.1
    • Component/s: tapestry-core
    • Labels:
      None
    • Environment:
      Tapestry 5.1.0.5
      JDK5

      Description

      Below is the example
      KeyedObject.java:used to store string keyed object
      import java.util.*;
      import java.util.Map.Entry;
      public class KeyedObject<T> {
      private String key;
      private T value;
      public String getKey()

      { return key; }

      public void setKey(String key)

      { this.key = key; }

      public T getValue()

      { return value; }

      public void setValue(T value)

      { this.value = value; }


      }

      page java class:dbpools simply put BasicDataSource and its key name into a KeyObject list
      import java.util.Iterator;
      import java.util.LinkedList;
      import java.util.List;
      import java.util.Map;
      import java.util.Map.Entry;

      import org.apache.commons.dbcp.BasicDataSource;
      import org.apache.tapestry5.annotations.Property;
      import org.apache.tapestry5.ioc.annotations.Inject;

      import com.elite.predictob.EliteOBManagerProxy;
      import com.elite.predictob.KeyedObject;

      public class dbpools {
      @Inject
      private EliteOBManagerProxy proxy;

      @Property
      private KeyedObject<BasicDataSource> datasource;

      public List<KeyedObject<BasicDataSource>> getDatasources()
      {
      Map dbmap=proxy.getManager().getDataSources();
      synchronized (dbmap) {
      List<KeyedObject<BasicDataSource>> list=new LinkedList<KeyedObject<BasicDataSource>>();
      Iterator<Entry<String,BasicDataSource>> it=dbmap.entrySet().iterator();
      while(it.hasNext())

      { Entry<String,BasicDataSource> entry=it.next(); KeyedObject<BasicDataSource> obj=new KeyedObject<BasicDataSource>(); obj.setKey(entry.getKey()); obj.setValue(entry.getValue()); list.add(obj); }

      return list;
      }
      }
      }

      page template:
      <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
      xmlns="tapestry:parameter"
      xmlns:cl="cl">
      <head>
      <t:elite.cachecontrol.cachecontrol/>
      <title>$

      {message:dbpoolconfig}

      </title>
      </head>
      <body>
      <table border="1">
      <tr t:type="loop" t:element="tr" t:source="datasources" value="datasource">
      <td>$

      {datasource.key}

      </td><td>$

      {datasource.value.numActive}</td>
      </tr>
      </table>
      </body>
      </html>


      ${datasource.value.numActive}

      will cause following error:
      Could not convert 'datasource.value.numActive' into a component parameter binding: Class java.lang.Object does not contain a property named 'numActive' (within property expression 'datasource.value.numActive'). Available properties: class.

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        59d 11h 37m 1 Thiago H. de Paula Figueiredo 16/Oct/09 14:03
        Closed Closed Reopened Reopened
        305d 10h 22m 1 Howard M. Lewis Ship 18/Aug/10 00:25
        Reopened Reopened Closed Closed
        22s 1 Howard M. Lewis Ship 18/Aug/10 00:25
        Hide
        Hudson added a comment -

        Integrated in tapestry-5.2-freestyle #173 (See https://hudson.apache.org/hudson/job/tapestry-5.2-freestyle/173/)
        TAP5-818: Tapestry should properly support JDK 1.5 Generics when reading and updating properties and property expressions

        Show
        Hudson added a comment - Integrated in tapestry-5.2-freestyle #173 (See https://hudson.apache.org/hudson/job/tapestry-5.2-freestyle/173/ ) TAP5-818 : Tapestry should properly support JDK 1.5 Generics when reading and updating properties and property expressions
        Howard M. Lewis Ship made changes -
        Status Reopened [ 4 ] Closed [ 6 ]
        Fix Version/s 5.2.1 [ 12315230 ]
        Resolution Fixed [ 1 ]
        Hide
        Howard M. Lewis Ship added a comment -

        Thanks Josh .... great patch (just watch those code reformats).

        Show
        Howard M. Lewis Ship added a comment - Thanks Josh .... great patch (just watch those code reformats).
        Howard M. Lewis Ship made changes -
        Resolution Won't Fix [ 2 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Howard M. Lewis Ship made changes -
        Summary JDK5 Generic is not supported by property chain Tapestry should properly support JDK 1.5 Generics when reading and updating properties and property expressions
        Howard M. Lewis Ship made changes -
        Assignee Howard M. Lewis Ship [ hlship ]
        Josh Canfield made changes -
        Attachment PropertyConduitGenerics.patch [ 12452337 ]
        Hide
        Josh Canfield added a comment -

        Here is a patch that adds support for Property level generic support to the PropertyConduitSource.
        It also fixes a bug where an ArrayIndexOutOfBounds exception could occur if you had multiple levels of Generics with different numbers of arguments.

        class One<A,B>

        class Two<A> extends One<String, A>

        class Three extends Two<Long>

        Show
        Josh Canfield added a comment - Here is a patch that adds support for Property level generic support to the PropertyConduitSource. It also fixes a bug where an ArrayIndexOutOfBounds exception could occur if you had multiple levels of Generics with different numbers of arguments. class One<A,B> class Two<A> extends One<String, A> class Three extends Two<Long>
        Hide
        Josh Canfield added a comment -

        "As the type of T is not known until runtime, all Tapestry know is that T is Object."

        Actually everything needed to support this case is available when the PropertyConduit is created. Tapestry is currently evaluating the expression without considering the context provided by the class which owns the property.

        Show
        Josh Canfield added a comment - "As the type of T is not known until runtime, all Tapestry know is that T is Object." Actually everything needed to support this case is available when the PropertyConduit is created. Tapestry is currently evaluating the expression without considering the context provided by the class which owns the property.
        Thiago H. de Paula Figueiredo made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Won't Fix [ 2 ]
        Hide
        Thiago H. de Paula Figueiredo added a comment -

        Tapestry's prop binding uses class creation, not reflection, to get and set values. As the type of T is not known until runtime, all Tapestry know is that T is Object.

        Show
        Thiago H. de Paula Figueiredo added a comment - Tapestry's prop binding uses class creation, not reflection, to get and set values. As the type of T is not known until runtime, all Tapestry know is that T is Object.
        maxyu made changes -
        Affects Version/s 5.1.0.5 [ 12313913 ]
        Component/s tapestry-core [ 12312470 ]
        Hide
        Shane Curcuru added a comment -

        I presume this is a Tapestry issue; otherwise please reassign as needd. This is not related to the PRC project (which is public relations).

        Show
        Shane Curcuru added a comment - I presume this is a Tapestry issue; otherwise please reassign as needd. This is not related to the PRC project (which is public relations).
        Shane Curcuru made changes -
        Field Original Value New Value
        Project Public Relations [ 12310837 ] Tapestry 5 [ 12310833 ]
        Key PRC-14 TAP5-818
        Security PRC private [ 10052 ]
        maxyu created issue -

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            maxyu
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development