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);
}
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;
}
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;
}
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());
}
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()));
}
Aggregations