You could supply a custom ValueEncoder for MySuperObject that would handle either case and make your code agnostic to the type of object.
You could use: onActivate(EventContext context) And then grab the parameter values and convert as desired using the "get" method (but that will require you to have some knowledge of what type of object it is). One possibility would be to encode two values into the context, something like (untested code; in particular, the generics are off): List<Object> onPassivate() { return Arrays.asList(myObject.getClass().getSimpleName(),myObject); } onActivate(EventContext context) {//I'm assuming that the objects are entities and are being encoded to an integer or long id... Class desiredType = ...//some code to generate the type. It could be as simple as: "MyObject1".equals(context.get(String.class,0))?MyObject1.class:MyObject2.class MySuperObject myObject = context.get(desiredType, 1); //do stuff } But there's not a way to do what you're asking directly. Activate event handler precedence is determined by the number of parameters. Tapestry tries to match the number of context parameters with the number of parameters in an activate handler, then attempts to coerce the string parameter values into the types specified in the activate method signature. So you can't have two onActivate methods with a single method parameter because there's no way for Tapestry to know which one to use: it will pick one and attempt to coerce the parameter to said type. Robert On Jul 19, 2011, at 7/1911:55 AM , Ulrich VACHON wrote: > Hi all, > > I would to know if it's possible to have several onActivate methods with > differents parameters type. In fact, I have two objects class with this > hierarchy : > > MySuperObject > ^ ^ > / \ > MyObject1 MyObject2 > > And I want to navigate with any objects and have different behavior in page, > like: > > onActive(MyObject1 myObject1) { > // some works with myObject1 instance... > } > > onActive(MyObject2 myObject2) { > // some works with myObject2 instance... > } > > Unfortunately I have a ClassCastException... > > An idea? > > Regards, > Ulrich > > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/Multiple-onActive-tp4612951p4612951.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