The generics support in 5.1 is pretty limited. I've implemented a patch for 5.2 that should solve your problem which will be checked into the trunk soon. Since you've provided a good use case I'll add it to the unit tests when I get to a computer. I'm not sure that it will be back-ported to 5.1 (is generics support a feature or bug fix?)
-- Josh On Sep 10, 2010, at 2:17 PM, danrwilliams <dan_r_willi...@yahoo.co.uk> wrote: > > Hi, > > I am trying to standardise the way our developers code a page class that > uses a Grid component. Part of this process is defining an interface that > contains the get/set methods for the property used in the row parameter of > the Grid component. > > Since the data used in any Grid in our project will always extend from a > specific super-type, I have created a bounded generic interface to give type > safety to the get/set methods in the page class. > > The problem is, Tapestry 5.1.0.5 doesn't seem to honour this. > > I'll try to illustrate.. > > Our code looks something like this; > > class MyPageClass implements MyInterface<MyGridRowType> { > ... > ... > @Override > public MyGridRowType getRow() {...} > > @Override > public void setRow(MyGridRowType row) {...} > > ... > } > > interface MyInterface<T extends GridRowSupertype> { > > T getRow(): > > void setRow(T row): > } > > interface GridRowSupertype { > String getStringA(); > } > > class MyGridRowType implements GridRowSupertype { > > @Override > public String getStringA() {...} > > public String getStringB() {...} > } > > Now, in the Grid component in our template file, if I try to use > '${row.stringb}' Tapestry throws an exception saying; > > "...Class GridRowSupertype does not contain a property named 'stringb'... > ...Available properties: stringa..." > > Even though this is technically correct, Tapestry is referencing the > super-type and not the sub-type supplied by the page class. The return type > on the getRow() method in the page class is MyGridRowType, which does > contain the required method (getStringB). > > I have confirmed this by simply removing the interface 'MyInterface' from > the page class and everything works fine. > > Any suggestions? > > Thanks, > Dan > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/Generics-problem-with-Grid-row-parameter-tp2835598p2835598.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org