Example usage for org.apache.wicket SharedResources remove

List of usage examples for org.apache.wicket SharedResources remove

Introduction

In this page you can find the example usage for org.apache.wicket SharedResources remove.

Prototype

public final ResourceReference remove(final Key key) 

Source Link

Document

Removes a resource.

Usage

From source file:net.databinder.components.RenderedLabel.java

License:Open Source License

@Override
protected void onBeforeRender() {
    super.onBeforeRender();
    int curHash = getLabelHash();
    if (isShared) {
        if (labelHash != curHash) {
            String hash = Integer.toHexString(curHash);
            SharedResources shared = getApplication().getSharedResources();
            try {
                resource = (RenderedTextImageResource) shared.get(RenderedLabel.class, hash, null, null, false);
            } catch (ClassCastException e) {
                // was placeholder for missing PackageResourceReference
                shared.remove(shared.resourceKey(RenderedLabel.class, hash, null, null));
            }/*from   w  w  w  .  j av  a 2  s .c  o  m*/
            if (resource == null)
                shared.add(RenderedLabel.class, hash, null, null,
                        resource = newRenderedTextImageResource(true));
            setImageResourceReference(new ResourceReference(RenderedLabel.class, hash));
        }
    } else {
        if (resource == null)
            setImageResource(resource = newRenderedTextImageResource(false));
        else if (labelHash != curHash)
            resource.setState(this);
    }
    resource.setCacheable(isShared);
    labelHash = getLabelHash();
}