Search in sources :

Example 1 with ResourceReference

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

the class CoreLibrariesContributor method contribute.

/**
 * Contributes the backing library plus the implementation of Wicket.Event.
 *
 * @param application
 *            the application instance
 * @param response
 *            the current header response
 */
public static void contribute(final Application application, final IHeaderResponse response) {
    JavaScriptLibrarySettings jsLibrarySettings = application.getJavaScriptLibrarySettings();
    ResourceReference wicketAjaxReference = jsLibrarySettings.getWicketAjaxReference();
    response.render(JavaScriptHeaderItem.forReference(wicketAjaxReference));
}
Also used : JavaScriptLibrarySettings(org.apache.wicket.settings.JavaScriptLibrarySettings) ResourceReference(org.apache.wicket.request.resource.ResourceReference)

Example 2 with ResourceReference

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

the class JQueryPluginResourceReference method getDependencies.

@Override
public List<HeaderItem> getDependencies() {
    final ResourceReference backingLibraryReference;
    if (Application.exists()) {
        backingLibraryReference = Application.get().getJavaScriptLibrarySettings().getJQueryReference();
    } else {
        backingLibraryReference = DynamicJQueryResourceReference.get();
    }
    List<HeaderItem> dependencies = super.getDependencies();
    dependencies.add(JavaScriptHeaderItem.forReference(backingLibraryReference));
    return dependencies;
}
Also used : JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) ResourceReference(org.apache.wicket.request.resource.ResourceReference) HeaderItem(org.apache.wicket.markup.head.HeaderItem) JavaScriptHeaderItem(org.apache.wicket.markup.head.JavaScriptHeaderItem)

Example 3 with ResourceReference

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

the class WicketTesterTest method clickResourceLinkWithResourceReference.

/**
 * https://issues.apache.org/jira/browse/WICKET-4810
 *
 * Clicking on ResourceLink should deliver the resource reference's content
 */
@Test
public void clickResourceLinkWithResourceReference() {
    MockPageWithLink page = new MockPageWithLink();
    String content = "content";
    final ByteArrayResource resource = new ByteArrayResource("text/plain", content.getBytes(), "fileName.txt");
    ResourceReference reference = new ResourceReference(WicketTesterTest.class, "resourceLinkWithResourceReferenceTest") {

        @Override
        public IResource getResource() {
            return resource;
        }
    };
    ResourceLink<Void> link = new ResourceLink<Void>(MockPageWithLink.LINK_ID, reference);
    page.add(link);
    tester.startPage(page);
    tester.clickLink(MockPageWithLink.LINK_ID, false);
    assertEquals(tester.getContentTypeFromResponseHeader(), "text/plain");
    assertEquals(content, tester.getLastResponseAsString());
}
Also used : ResourceLink(org.apache.wicket.markup.html.link.ResourceLink) ByteArrayResource(org.apache.wicket.request.resource.ByteArrayResource) ResourceReference(org.apache.wicket.request.resource.ResourceReference) MockPageWithLink(org.apache.wicket.MockPageWithLink) Test(org.junit.Test)

Example 4 with ResourceReference

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

the class Image method setImageResourceReferences.

/**
 * @param parameters
 *            Set the resource parameters for the resource.
 * @param resourceReferences
 *            The resource references to set.
 */
public void setImageResourceReferences(final PageParameters parameters, final ResourceReference... resourceReferences) {
    localizedImageResources.clear();
    for (ResourceReference resourceReference : resourceReferences) {
        LocalizedImageResource localizedImageResource = new LocalizedImageResource(this);
        if (parameters != null) {
            localizedImageResource.setResourceReference(resourceReference, parameters);
        } else {
            localizedImageResource.setResourceReference(resourceReference);
        }
        localizedImageResources.add(localizedImageResource);
    }
}
Also used : LocalizedImageResource(org.apache.wicket.markup.html.image.resource.LocalizedImageResource) ResourceReference(org.apache.wicket.request.resource.ResourceReference)

Example 5 with ResourceReference

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

the class Video method onComponentTag.

@Override
protected void onComponentTag(ComponentTag tag) {
    checkComponentTag(tag, "video");
    super.onComponentTag(tag);
    Integer _width = getWidth();
    if (_width != null) {
        tag.put("width", _width);
    }
    Integer _height = getHeight();
    if (_height != null) {
        tag.put("height", _height);
    }
    ResourceReference _poster = getPoster();
    if (_poster != null) {
        tag.put("poster", RequestCycle.get().urlFor(_poster, getPosterPageParameters()));
    }
}
Also used : ResourceReference(org.apache.wicket.request.resource.ResourceReference)

Aggregations

ResourceReference (org.apache.wicket.request.resource.ResourceReference)46 IResource (org.apache.wicket.request.resource.IResource)10 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)8 SharedResourceReference (org.apache.wicket.request.resource.SharedResourceReference)7 Test (org.junit.Test)7 ResourceReferenceRequestHandler (org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler)6 HeaderItem (org.apache.wicket.markup.head.HeaderItem)5 Url (org.apache.wicket.request.Url)5 JavaScriptResourceReference (org.apache.wicket.request.resource.JavaScriptResourceReference)5 JavaScriptLibrarySettings (org.apache.wicket.settings.JavaScriptLibrarySettings)5 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)4 Page (org.apache.wicket.Page)3 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)3 JavaScriptHeaderItem (org.apache.wicket.markup.head.JavaScriptHeaderItem)3 Image (org.apache.wicket.markup.html.image.Image)3 Properties (java.util.Properties)2 Application (org.apache.wicket.Application)2 StringResourceModel (org.apache.wicket.model.StringResourceModel)2 ByteArrayResource (org.apache.wicket.request.resource.ByteArrayResource)2 CssResourceReference (org.apache.wicket.request.resource.CssResourceReference)2