You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/03/21 05:04:55 UTC
T5: generic, onActivate and onPassivate
Hi,
I'm trying out generic in 5.0.11, I have a base class ObjectEdit, then
public class ObjectEdit<T> {
private T object;
public T getObject() { return object;}
public void setObject(T object) { this.object = object;}
public void onActivate(T obj) { object = obj;}
public T onPassivate() { return object; }
}
I was hoping that I can just extend it like this:
public class UserEdit extends ObjectEdit <Usr> {
}
but it does not work, error:
org.apache.tapestry.ioc.internal.util.TapestryException
Failure reading parameter 'object' of component admin/UserEdit:object:
java.lang.String
I have to do:
public class UserEdit extends ObjectEdit <User> {
public void onActivate(User obj) {
this.setObject(obj);
}
}
and remove the onActivate from ObjectEdit, why onActivate does not work in a
base class when onPassivate can? Thanks,
A.C.
--
View this message in context: http://www.nabble.com/T5%3A-generic%2C-onActivate-and-onPassivate-tp16193600p16193600.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: generic, onActivate and onPassivate
Posted by Davor Hrg <hr...@gmail.com>.
javassist has low level apis that allow accessing
elements reflective data, and after that it's same old reflection code,
for example when I treid t make GenericComponents for tapestry
I wanted to make a worker and put generic information into ComponentResources
@Component private EntityEditComponent<Vessel, Long> _vesselEdit;
I found the way to get the declaration for the field from javassist:
I messed a bit with
//ClassTransformation is enhanced to return :
CtField.getFieldInfo2...
FieldInfo info = transformation.getFieldInfo2(fieldName);
SignatureAttribute.ClassType type = (ClassType)
SignatureAttribute.toFieldSignature(sig.getSignature());
System.out.println(fieldName+":TYPE:"+type);//QDEBUG remove
TypeArgument[] typeArguments = type.getTypeArguments();
for (int i = 0; i < typeArguments.length; i++) {
System.out.println("TYPE par:
"+typeArguments[i]);//QDEBUG remove
}
the output is :
_vesselEdit:TYPE:tapestryutil.base.EntityEditComponent<hr.crup.eri.web.entities.Vessel,
java.lang.Long>
TYPE par: hr.crup.eri.web.entities.Vessel
TYPE par: java.lang.Long
after that I just could not get the parameter into ComponentResources
this was all nice but after some digging I found this nice class on jboss
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossretro/trunk/src/main/java/org/jboss/lang/GenericsHelper.java/?revision=227&view=markup&pathrev=227
it has all you need for generics in javassist
Davor Hrg
On Fri, Mar 21, 2008 at 11:21 PM, Howard Lewis Ship <hl...@gmail.com> wrote:
> Yes ... but that information isn't always exposed properly via the
> Javassist APIs.
>
>
>
> On Fri, Mar 21, 2008 at 3:19 AM, Davor Hrg <hr...@gmail.com> wrote:
> > Method parameter types contain generic information just like
> > properties and method return types. It is quite similar to stuff
> > in property conduit source.
> >
> > Davor Hrg
> >
> >
> >
> >
> > On Fri, Mar 21, 2008 at 6:41 AM, Howard Lewis Ship <hl...@gmail.com> wrote:
> > > Yes, I think the generics logic isn't smart enough for this case, that
> > > is, to identify and convert the parameter of the event handler method.
> > > You can add this as a bug, but I'm not even sure how to start making
> > > this work correctly!
> > >
> > >
> > >
> > > On Thu, Mar 20, 2008 at 9:04 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
> > > >
> > > > Hi,
> > > >
> > > > I'm trying out generic in 5.0.11, I have a base class ObjectEdit, then
> > > >
> > > > public class ObjectEdit<T> {
> > > >
> > > > private T object;
> > > > public T getObject() { return object;}
> > > > public void setObject(T object) { this.object = object;}
> > > > public void onActivate(T obj) { object = obj;}
> > > > public T onPassivate() { return object; }
> > > > }
> > > >
> > > > I was hoping that I can just extend it like this:
> > > >
> > > > public class UserEdit extends ObjectEdit <Usr> {
> > > > }
> > > >
> > > > but it does not work, error:
> > > > org.apache.tapestry.ioc.internal.util.TapestryException
> > > > Failure reading parameter 'object' of component admin/UserEdit:object:
> > > > java.lang.String
> > > >
> > > > I have to do:
> > > >
> > > > public class UserEdit extends ObjectEdit <User> {
> > > > public void onActivate(User obj) {
> > > > this.setObject(obj);
> > > > }
> > > > }
> > > >
> > > > and remove the onActivate from ObjectEdit, why onActivate does not work in a
> > > > base class when onPassivate can? Thanks,
> > > >
> > > > A.C.
> > > >
> > > >
> > > > --
> > > > View this message in context: http://www.nabble.com/T5%3A-generic%2C-onActivate-and-onPassivate-tp16193600p16193600.html
> > > > Sent from the Tapestry - User mailing list archive at Nabble.com.
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Howard M. Lewis Ship
> > >
> > > Creator Apache Tapestry and Apache HiveMind
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: generic, onActivate and onPassivate
Posted by Howard Lewis Ship <hl...@gmail.com>.
Yes ... but that information isn't always exposed properly via the
Javassist APIs.
On Fri, Mar 21, 2008 at 3:19 AM, Davor Hrg <hr...@gmail.com> wrote:
> Method parameter types contain generic information just like
> properties and method return types. It is quite similar to stuff
> in property conduit source.
>
> Davor Hrg
>
>
>
>
> On Fri, Mar 21, 2008 at 6:41 AM, Howard Lewis Ship <hl...@gmail.com> wrote:
> > Yes, I think the generics logic isn't smart enough for this case, that
> > is, to identify and convert the parameter of the event handler method.
> > You can add this as a bug, but I'm not even sure how to start making
> > this work correctly!
> >
> >
> >
> > On Thu, Mar 20, 2008 at 9:04 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
> > >
> > > Hi,
> > >
> > > I'm trying out generic in 5.0.11, I have a base class ObjectEdit, then
> > >
> > > public class ObjectEdit<T> {
> > >
> > > private T object;
> > > public T getObject() { return object;}
> > > public void setObject(T object) { this.object = object;}
> > > public void onActivate(T obj) { object = obj;}
> > > public T onPassivate() { return object; }
> > > }
> > >
> > > I was hoping that I can just extend it like this:
> > >
> > > public class UserEdit extends ObjectEdit <Usr> {
> > > }
> > >
> > > but it does not work, error:
> > > org.apache.tapestry.ioc.internal.util.TapestryException
> > > Failure reading parameter 'object' of component admin/UserEdit:object:
> > > java.lang.String
> > >
> > > I have to do:
> > >
> > > public class UserEdit extends ObjectEdit <User> {
> > > public void onActivate(User obj) {
> > > this.setObject(obj);
> > > }
> > > }
> > >
> > > and remove the onActivate from ObjectEdit, why onActivate does not work in a
> > > base class when onPassivate can? Thanks,
> > >
> > > A.C.
> > >
> > >
> > > --
> > > View this message in context: http://www.nabble.com/T5%3A-generic%2C-onActivate-and-onPassivate-tp16193600p16193600.html
> > > Sent from the Tapestry - User mailing list archive at Nabble.com.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> >
> > --
> > Howard M. Lewis Ship
> >
> > Creator Apache Tapestry and Apache HiveMind
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
Creator Apache Tapestry and Apache HiveMind
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: generic, onActivate and onPassivate
Posted by Davor Hrg <hr...@gmail.com>.
Method parameter types contain generic information just like
properties and method return types. It is quite similar to stuff
in property conduit source.
Davor Hrg
On Fri, Mar 21, 2008 at 6:41 AM, Howard Lewis Ship <hl...@gmail.com> wrote:
> Yes, I think the generics logic isn't smart enough for this case, that
> is, to identify and convert the parameter of the event handler method.
> You can add this as a bug, but I'm not even sure how to start making
> this work correctly!
>
>
>
> On Thu, Mar 20, 2008 at 9:04 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
> >
> > Hi,
> >
> > I'm trying out generic in 5.0.11, I have a base class ObjectEdit, then
> >
> > public class ObjectEdit<T> {
> >
> > private T object;
> > public T getObject() { return object;}
> > public void setObject(T object) { this.object = object;}
> > public void onActivate(T obj) { object = obj;}
> > public T onPassivate() { return object; }
> > }
> >
> > I was hoping that I can just extend it like this:
> >
> > public class UserEdit extends ObjectEdit <Usr> {
> > }
> >
> > but it does not work, error:
> > org.apache.tapestry.ioc.internal.util.TapestryException
> > Failure reading parameter 'object' of component admin/UserEdit:object:
> > java.lang.String
> >
> > I have to do:
> >
> > public class UserEdit extends ObjectEdit <User> {
> > public void onActivate(User obj) {
> > this.setObject(obj);
> > }
> > }
> >
> > and remove the onActivate from ObjectEdit, why onActivate does not work in a
> > base class when onPassivate can? Thanks,
> >
> > A.C.
> >
> >
> > --
> > View this message in context: http://www.nabble.com/T5%3A-generic%2C-onActivate-and-onPassivate-tp16193600p16193600.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: generic, onActivate and onPassivate
Posted by Howard Lewis Ship <hl...@gmail.com>.
Yes, I think the generics logic isn't smart enough for this case, that
is, to identify and convert the parameter of the event handler method.
You can add this as a bug, but I'm not even sure how to start making
this work correctly!
On Thu, Mar 20, 2008 at 9:04 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi,
>
> I'm trying out generic in 5.0.11, I have a base class ObjectEdit, then
>
> public class ObjectEdit<T> {
>
> private T object;
> public T getObject() { return object;}
> public void setObject(T object) { this.object = object;}
> public void onActivate(T obj) { object = obj;}
> public T onPassivate() { return object; }
> }
>
> I was hoping that I can just extend it like this:
>
> public class UserEdit extends ObjectEdit <Usr> {
> }
>
> but it does not work, error:
> org.apache.tapestry.ioc.internal.util.TapestryException
> Failure reading parameter 'object' of component admin/UserEdit:object:
> java.lang.String
>
> I have to do:
>
> public class UserEdit extends ObjectEdit <User> {
> public void onActivate(User obj) {
> this.setObject(obj);
> }
> }
>
> and remove the onActivate from ObjectEdit, why onActivate does not work in a
> base class when onPassivate can? Thanks,
>
> A.C.
>
>
> --
> View this message in context: http://www.nabble.com/T5%3A-generic%2C-onActivate-and-onPassivate-tp16193600p16193600.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
Creator Apache Tapestry and Apache HiveMind
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org