Hi,
I am trying to create a component right now that requires an asset. The
asset is properly specified as a context-asset in the .jwc file.
I wanted to keep a reference to the image in a static variable because
it does not change. However, I can't load the image in the
constructor...
public class HomeLink extends AbstractComponent {
private static IAsset image;
public HomeLink() {
super();
if (image == null) {
image = getAsset("menuImage");
// image is always null at this point!
}
}
protected void renderComponent(IMarkupWriter w, IRequestCycle c) {
image = getAsset("menuImage");
// asset is properly loaded
}
}
My question now is, what is the proper way to load assets?
- implement a PageRenderListener that does the initialization (would it
be called for a component?)
- initialize the asset in the renderComponent method?
- not store the reference for the asset at all (maybe the assets are
internally cached anyway)?
Best,
Dirk Dittert
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]