List of usage examples for org.apache.wicket.protocol.http WebApplication mountResource
public ResourceMapper mountResource(final String path, final ResourceReference reference)
From source file:org.wickedsource.wickedforms.wicket6.components.FormPanel.java
License:Apache License
private void mountResources() { WebApplication application = ((WebApplication) getApplication()); application.mountResource("wickedforms/invalid.png", new PackageResourceReference(FormPanel.class, "invalid.png")); application.mountResource("wickedforms/red_asterisk.png", new PackageResourceReference(FormPanel.class, "red_asterisk.png")); application.mountResource("wickedforms/valid.png", new PackageResourceReference(FormPanel.class, "valid.png")); }
From source file:org.wicketstuff.jeeweb.ajax.JEEWebGlobalAjaxHandler.java
License:Apache License
/** * Configures the handler to the given application. * // w w w . j ava 2s. co m * @param application * the application to configure the handler to */ public static void configure(WebApplication application) { application.getRequestCycleListeners().add(new PageRequestHandlerTracker()); application.mountResource("/" + JEEWebGlobalAjaxHandler.class.getSimpleName(), new JEEWebGlobalAjaxHandler()); application.getHeaderContributorListeners().add(new IHeaderContributor() { private static final long serialVersionUID = 1644041155625458328L; @Override public void renderHead(IHeaderResponse response) { JavaScriptResourceReference forReference = new JavaScriptResourceReference( JEEWebGlobalAjaxHandler.class, JEEWebGlobalAjaxHandler.class.getSimpleName() + ".js") { private static final long serialVersionUID = -3649384632770480975L; @Override public List<HeaderItem> getDependencies() { return new ArrayList<HeaderItem>() { private static final long serialVersionUID = 1L; { add(JavaScriptHeaderItem.forReference(WicketAjaxJQueryResourceReference.get())); } }; } }; response.render(JavaScriptHeaderItem.forReference(forReference)); addAJaxBaseUrl(response); } private void addAJaxBaseUrl(IHeaderResponse response) { // render ajax base url. It's required by Wicket Ajax support. Url baseUrl = RequestCycle.get().getUrlRenderer().getBaseUrl(); CharSequence ajaxBaseUrl = Strings.escapeMarkup(baseUrl.toString()); response.render(JavaScriptHeaderItem.forScript("Wicket.Ajax.baseUrl=\"" + ajaxBaseUrl + "\";", "wicket-ajax-base-url")); } }); }
From source file:org.wicketstuff.offline.mode.OfflineCache.java
License:Apache License
/** * Initializes the offline cache (used in the init method of a wicket application) * //from ww w. j a va 2 s .c o m * @param webApplication * the web application to mount the offline cache references * @param cacheName * the cache name * @param offlineCacheEntries * the offline cache entries to be cached */ public static void init(WebApplication webApplication, String cacheName, List<OfflineCacheEntry> offlineCacheEntries) { OfflineCache.setOfflineCacheEntries(webApplication, offlineCacheEntries); webApplication.mountResource("wicket-offlinecache-serviceworkerregistration", ServiceWorkerRegistration.getInstance()); webApplication.mountResource("wicket-offlinecache-serviceworker", new ServiceWorker(cacheName, offlineCacheEntries)); }
From source file:org.wicketstuff.rest.utils.mounting.PackageScanner.java
License:Apache License
private static void mountAnnotatedResource(WebApplication application, Class<?> clazz) throws InstantiationException, IllegalAccessException { ResourcePath mountAnnotation = clazz.getAnnotation(ResourcePath.class); if (mountAnnotation == null || !IResource.class.isAssignableFrom(clazz)) { return;/*from w w w. ja va 2 s . co m*/ } String path = mountAnnotation.value(); final IResource resourceInstance = (IResource) clazz.newInstance(); application.mountResource(path, new ResourceReference(clazz.getSimpleName()) { /** * */ private static final long serialVersionUID = 1L; @Override public IResource getResource() { return resourceInstance; } }); log.info("Resource '" + clazz.getSimpleName() + "' has been mounted to path '" + path + "'"); }
From source file:org.yes.cart.web.theme.impl.WicketResourceMounterImpl.java
License:Apache License
/** {@inheritDoc} */ @Override// w ww . j av a2 s. c o m public void mountResources(final WebApplication webApplication) { webApplication.mountResource("/sitemap.xml", new ResourceReference("sitemap.xml") { @Override public IResource getResource() { return sitemapXml; } }); webApplication.mountResource("/orderreceipt.pdf", new ResourceReference("orderreceipt.pdf") { @Override public IResource getResource() { return orderPdf; } }); }