You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Lance Java <la...@googlemail.com> on 2008/06/13 16:09:12 UTC
Component is null in mixin
My last post did not get a response so perhaps including some code might
help.
I have a mixin which I attach to a custom component but the component is
null in the afterRender method of my mixin
It appears that @InjectContainer is not working... is there something I need
to add to my component? (MixinAny)
/**
* This class is like the standard Any component except it supports
getClientId() for use in mixins
*/
@SupportsInformalParameters
public class MixinAny implements ClientElement {
@Inject
private ComponentResources resources;
@Inject
private PageRenderSupport support;
private String clientId;
@Mixin @SuppressWarnings("unused")
private DiscardBody discardBody; // I copied this from the Field
component looking at the autocomplete mixin
@Mixin @SuppressWarnings("unused")
private RenderInformals renderInformals;
@BeginRender
protected void beginRender(MarkupWriter writer)
{
clientId = support.allocateClientId(resources);
writer.element(resources.getElementName(null));
writer.attributes("id", getClientId());
resources.renderInformalParameters(writer);
}
@AfterRender
protected void afterRender(MarkupWriter writer)
{
writer.end(); // the element
}
/**
*/
public String getClientId() {
return clientId;
}
}
@IncludeJavaScriptLibrary({
"context:/layout/javascript/jquery.js",
"context:/layout/javascript/interface.js"
})
@MixinAfter
public class SortableTarget {
private static final Logger LOGGER =
Logger.getLogger(SortableTarget.class);
@Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX)
private String accept; // this is populated
@InjectContainer
private ClientElement container; //This should be my MixinAny component
but is null
@Inject
private PageRenderSupport renderSupport; // this is populated
@AfterRender
public void afterRender() {
// container is null here
}
}
Cheers,
Lance.