Search in sources :

Example 6 with ResourceReference

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

the class ImageButton method onComponentTag.

/**
 * Processes the component tag.
 *
 * @param tag
 *            Tag to modify
 * @see org.apache.wicket.Component#onComponentTag(ComponentTag)
 */
@Override
protected final void onComponentTag(final ComponentTag tag) {
    checkComponentTag(tag, "input");
    checkComponentTagAttribute(tag, "type", "image");
    final IResource resource = getImageResource();
    if (resource != null) {
        localizedImageResource.setResource(resource);
    }
    final ResourceReference resourceReference = getImageResourceReference();
    if (resourceReference != null) {
        localizedImageResource.setResourceReference(resourceReference);
    }
    localizedImageResource.setSrcAttribute(tag);
    super.onComponentTag(tag);
}
Also used : ResourceReference(org.apache.wicket.request.resource.ResourceReference) IResource(org.apache.wicket.request.resource.IResource)

Example 7 with ResourceReference

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

the class ResourceAggregator method preserveJavaScriptDetails.

/**
 * Preserves the resource reference details for JavaScript resource replacements.
 *
 * For example if CSS resource with media <em>screen</em> is replaced with
 * {@link org.apache.wicket.protocol.http.WebApplication#addResourceReplacement(org.apache.wicket.request.resource.JavaScriptResourceReference, org.apache.wicket.request.resource.ResourceReference)} then the replacement will
 * will inherit the media attribute
 *
 * @param item   The replaced header item
 * @param bundle The bundle that represents the replacement
 * @return the bundle with the preserved details
 */
private HeaderItem preserveJavaScriptDetails(JavaScriptReferenceHeaderItem item, JavaScriptReferenceHeaderItem bundle) {
    HeaderItem resultBundle;
    ResourceReference bundleReference = bundle.getReference();
    if (bundleReference instanceof ReplacementResourceBundleReference) {
        resultBundle = JavaScriptHeaderItem.forReference(bundleReference, item.getPageParameters(), item.getId(), item.isDefer(), item.getCharset(), item.getCondition());
    } else {
        resultBundle = bundle;
    }
    return resultBundle;
}
Also used : ReplacementResourceBundleReference(org.apache.wicket.resource.bundles.ReplacementResourceBundleReference) ResourceReference(org.apache.wicket.request.resource.ResourceReference)

Example 8 with ResourceReference

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

the class OnDomReadyHeaderItem method getDependencies.

@Override
public List<HeaderItem> getDependencies() {
    JavaScriptLibrarySettings ajaxSettings = Application.get().getJavaScriptLibrarySettings();
    ResourceReference wicketAjaxReference = ajaxSettings.getWicketAjaxReference();
    List<HeaderItem> dependencies = super.getDependencies();
    dependencies.add(JavaScriptHeaderItem.forReference(wicketAjaxReference));
    return dependencies;
}
Also used : JavaScriptLibrarySettings(org.apache.wicket.settings.JavaScriptLibrarySettings) ResourceReference(org.apache.wicket.request.resource.ResourceReference)

Example 9 with ResourceReference

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

the class ParentResourceEscapePathTest method resourceUrlGeneratedByResourceReference.

private void resourceUrlGeneratedByResourceReference() {
    final ResourceReference ref = new PackageResourceReference(ParentResourceEscapePathTestPage.class, "../../../ParentResourceTest.js");
    assertContains(tester.getRequestCycle().mapUrlFor(ref, null).toString(), expectedResourceUrl());
}
Also used : PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) ResourceReference(org.apache.wicket.request.resource.ResourceReference)

Example 10 with ResourceReference

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

the class UploadProgressBar method renderHead.

/**
 * {@inheritDoc}
 */
@Override
public void renderHead(final IHeaderResponse response) {
    super.renderHead(response);
    CoreLibrariesContributor.contributeAjax(getApplication(), response);
    response.render(JavaScriptHeaderItem.forReference(JS));
    ResourceReference css = getCss();
    if (css != null) {
        response.render(CssHeaderItem.forReference(css));
    }
    ResourceReference ref = new SharedResourceReference(RESOURCE_NAME);
    final String uploadFieldId = (uploadField == null) ? "" : uploadField.getMarkupId();
    final String status = new StringResourceModel(RESOURCE_STARTING, this, (IModel<?>) null).getString();
    CharSequence url = urlFor(ref, UploadStatusResource.newParameter(getPage().getId()));
    StringBuilder builder = new StringBuilder(128);
    Formatter formatter = new Formatter(builder);
    formatter.format("new Wicket.WUPB('%s', '%s', '%s', '%s', '%s', '%s');", getCallbackForm().getMarkupId(), statusDiv.getMarkupId(), barDiv.getMarkupId(), url, uploadFieldId, status);
    response.render(OnDomReadyHeaderItem.forScript(builder.toString()));
}
Also used : SharedResourceReference(org.apache.wicket.request.resource.SharedResourceReference) IModel(org.apache.wicket.model.IModel) Formatter(java.util.Formatter) SharedResourceReference(org.apache.wicket.request.resource.SharedResourceReference) CssResourceReference(org.apache.wicket.request.resource.CssResourceReference) JavaScriptResourceReference(org.apache.wicket.request.resource.JavaScriptResourceReference) ResourceReference(org.apache.wicket.request.resource.ResourceReference) StringResourceModel(org.apache.wicket.model.StringResourceModel)

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