On Tue, 28 Feb 2012 06:40:41 -0300, Paul Stanton <p...@mapshed.com.au> wrote:

Hi Tapestry committers/experts (in particular)

Hi!

Please take note of the method "idealImplementation". This is how I expected to be able to implement the functionality, however a ClassCastException is thrown casting the Component to a Zone. The object being cast is definitely a zone but it turns out that there is a classloader conflict in that the Zone of the returned object seems to come from the Plastic classloader, while the type I'm trying to cast it to comes from the standard classloader.

This explanation seems correct.

The only way I have found to workaround this situation is to avoid the cast altogether, which involves using reflection.

Don't cast to classes in controlled packages unless you are in a controlled package. Deep in Tapestry, everything that can be rendered is a RenderCommand and all components are Component instances. RenderCommand and Component are interfaces which aren't in controlled packages, so it's safe to cast to them everywhere.

For your specific scenario, AjaxResponseRenderer has an addRender(String clientId, Object renderer). Notice the renderer parameter can be anything which is a Block, Component or can be coerced to a RenderCommand. It also has an addRender(ClientBodyElement zone). Notice Zone implements ClientBodyElement, so your idealImplementation() method should work if you change your casts from Zone to ClientBodyElement.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to