tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard M. Lewis Ship (JIRA)" <...@tapestry.apache.org>
Subject [jira] Commented: (TAPESTRY-1518) Add support for JDK 1.5 Generics when defining pages and accessing bean properties
Date Thu, 24 Jan 2008 22:56:35 GMT

    [ https://issues.apache.org/jira/browse/TAPESTRY-1518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562271#action_12562271
] 

Howard M. Lewis Ship commented on TAPESTRY-1518:
------------------------------------------------

I'm slogging away at this one.

Something that will work today is that you can make your base class abstract, with abstract
getters and setters for the parameterized type,  In this way, when you implement the abstract
class, you will provide new methods that have the correct return type (even after type erasure)
... but then you need to redefine the field in each subclass, which is most of the work I
think you are trying to avoid.

What I'm seeing is that the data available at runtime is very limited; in the case of a non-abstract
base class, the Method objects are the Methods as defined on the base class (as type Object),
which kind of makes sense.

> Add support for JDK 1.5 Generics when defining pages and accessing bean properties
> ----------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-1518
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-1518
>             Project: Tapestry
>          Issue Type: Bug
>          Components: tapestry-core, tapestry-ioc
>    Affects Versions: 5.0, 5.0.3, 5.0.4
>            Reporter: Jun Tsai
>            Assignee: Howard M. Lewis Ship
>
> Base.java
> class abstract Base<T>{
>  private T entity;
>  public void setEntity(T t){
>   this.entity=entity;
>  }
>  public T getEntity(T t){
>   return this.entity;
>  }
>  protected abstract Class<T> getEntityClass();
>  onPrepareFromMyForm(){
>   if(this.entity == null){
>    try{
>      this.entity=getEntityClass().newInstance();
>    }catch(Exception e){
>      throw new RuntimeException(e);
>    }
>   }
>  }
>  .....
> }
> ProductPage.java
> public class ProductPage extends Base<Product>{
>  protected Class<Product> getEntityClass(){
>    return Product.class;
>  }
> }
> ProductPage.html
> <t:form t:id="MyForm">
>  <t:errors/>
>        <t:label for="input"/>
>        <input t:type="textfield" t:id="input" value="entity.name" size="40" t:validate="required,minlength=3"/>

>       <br/>
>       <input type="submit" value="Submit"/>
> </t:form>
> exception:
> Could not convert 'entity.name' into a component parameter binding: Class java.lang.Object
does not contain a property named 'name' (within property expression 'entity.name').
> When I debug the app,I fiind PropertyConduitSourceImpl.readMethodForTerm before onPrepareFromMyForm
method. 
> I think the method should be after onPrepareFromMyForm method.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message