Thanks Thiago, I wasn't fully aware of the 'controlled package' concept, however it does make sense.

I tried casting to 'ClientBodyElement' and while the cast works, I found the zone update does not succeed since at that point the object has not been assigned a clientId. I find this strange since I've just used the clientId to lookup the component.

So (at least part of) the workaround is still required. I can get rid of the reflection portion however, which was my main problem.

// Ideal solution: this doesn't work since the component (zone) hasn't yet been assigned a clientId ClientBodyElement zone = (ClientBodyElement) getEmbeddedComponent(container, zoneId);
        ajaxResponseRenderer.addRender(zone);

        // the following is a workaround
ClientBodyElement zone = (ClientBodyElement) getEmbeddedComponent(container, zoneId);
        ajaxResponseRenderer.addRender(zoneId, zone.getBody());

On 28/02/2012 9:50 PM, Thiago H. de Paula Figueiredo wrote:
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.


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

Reply via email to