Search in sources :

Example 1 with UrlResourceReference

use of org.apache.wicket.request.resource.UrlResourceReference in project wicket by apache.

the class UrlResourceReferenceMapper method mapHandler.

@Override
public Url mapHandler(IRequestHandler requestHandler) {
    Url url = null;
    if (requestHandler instanceof ResourceReferenceRequestHandler) {
        ResourceReferenceRequestHandler resourceReferenceRequestHandler = (ResourceReferenceRequestHandler) requestHandler;
        ResourceReference resourceReference = resourceReferenceRequestHandler.getResourceReference();
        while (resourceReference instanceof ResourceBundleReference) {
            // unwrap the bundle to render the url for the actual reference
            resourceReference = ((ResourceBundleReference) resourceReference).getBundleReference();
        }
        if (resourceReference instanceof UrlResourceReference) {
            UrlResourceReference urlResourceReference = (UrlResourceReference) resourceReference;
            url = urlResourceReference.getUrl();
        }
    }
    return url;
}
Also used : ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) UrlResourceReference(org.apache.wicket.request.resource.UrlResourceReference) ResourceBundleReference(org.apache.wicket.resource.bundles.ResourceBundleReference) UrlResourceReference(org.apache.wicket.request.resource.UrlResourceReference) ResourceReference(org.apache.wicket.request.resource.ResourceReference) Url(org.apache.wicket.request.Url)

Example 2 with UrlResourceReference

use of org.apache.wicket.request.resource.UrlResourceReference in project webanno by webanno.

the class ActionBarLink method onBeforeRender.

@Override
protected void onBeforeRender() {
    // the embedding component/page
    if (!hasBeenRendered()) {
        ResourceReference _imageRes = imageRes;
        if (_imageRes == null) {
            _imageRes = new UrlResourceReference(Url.parse(getString("icon"))).setContextRelative(true);
        }
        Image image = new Image("image", _imageRes);
        try {
            // The getString method throws an MissingResourceException if the property is
            // not available. In this case, we simply do not set a tooltip
            getString("tooltip");
            image.add(new AttributeModifier("title", new StringResourceModel("tooltip", ActionBarLink.this)));
        } catch (MissingResourceException e) {
        // Nothing to do
        }
        link.add(image);
    }
    super.onBeforeRender();
}
Also used : UrlResourceReference(org.apache.wicket.request.resource.UrlResourceReference) MissingResourceException(java.util.MissingResourceException) UrlResourceReference(org.apache.wicket.request.resource.UrlResourceReference) ResourceReference(org.apache.wicket.request.resource.ResourceReference) Image(org.apache.wicket.markup.html.image.Image) AttributeModifier(org.apache.wicket.AttributeModifier) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 3 with UrlResourceReference

use of org.apache.wicket.request.resource.UrlResourceReference in project wicket by apache.

the class CryptoMapperTest method urlResourceReference.

/**
 * UrlResourceReferences, WICKET-5319
 */
@Test
public void urlResourceReference() {
    UrlResourceReference resource = new UrlResourceReference(Url.parse("http://wicket.apache.org/"));
    Url url = mapper.mapHandler(new ResourceReferenceRequestHandler(resource));
    assertEquals("http://wicket.apache.org/", url.toString(StringMode.FULL));
}
Also used : ResourceReferenceRequestHandler(org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler) UrlResourceReference(org.apache.wicket.request.resource.UrlResourceReference) Url(org.apache.wicket.request.Url) Test(org.junit.Test)

Aggregations

UrlResourceReference (org.apache.wicket.request.resource.UrlResourceReference)3 Url (org.apache.wicket.request.Url)2 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)2 ResourceReference (org.apache.wicket.request.resource.ResourceReference)2 MissingResourceException (java.util.MissingResourceException)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 Image (org.apache.wicket.markup.html.image.Image)1 StringResourceModel (org.apache.wicket.model.StringResourceModel)1 ResourceBundleReference (org.apache.wicket.resource.bundles.ResourceBundleReference)1 Test (org.junit.Test)1