List of usage examples for org.apache.wicket.request.resource ResourceReference canBeRegistered
public boolean canBeRegistered()
From source file:name.martingeisse.wicket.helpers.Iframe.java
License:Open Source License
@Override protected void onComponentTag(final ComponentTag tag) { super.onComponentTag(tag); if (tag.isOpenClose()) { tag.setType(TagType.OPEN);/*from w w w . j a v a 2 s .c o m*/ } final Object modelObject = getDefaultModelObject(); if (modelObject instanceof IResource) { tag.put("src", urlFor(IResourceListener.INTERFACE, contentParameters)); } else if (modelObject instanceof ResourceReference) { final ResourceReference resourceReference = (ResourceReference) modelObject; if (resourceReference.canBeRegistered() && Application.exists()) { Application.get().getResourceReferenceRegistry().registerResourceReference(resourceReference); } tag.put("src", RequestCycle.get().urlFor(resourceReference, contentParameters)); } else if (modelObject instanceof IPageProvider) { setSrcAttribute(tag, (IPageProvider) modelObject); } else if (modelObject instanceof IRequestablePage) { setSrcAttribute(tag, new PageProvider((IRequestablePage) modelObject)); } else if (modelObject instanceof Class<?>) { final Class<?> c = (Class<?>) modelObject; if (Page.class.isAssignableFrom(c)) { setSrcAttribute(tag, new PageProvider(c.asSubclass(Page.class))); } else { throw new RuntimeException( "cannot handle iframe model object: Class<" + c.getCanonicalName() + ">"); } } else { throw new RuntimeException("cannot handle iframe model object: " + modelObject); } }
From source file:org.wicketstuff.rest.lambda.mounter.LambdaRestMounter.java
License:Apache License
/** * Mount rest resource./*from w w w. j av a 2 s . co m*/ * * @param httpMethod the http method * @param path the mounting path * @param resource the resource * @return the resource mapper */ protected ResourceMapper mountRestResource(final HttpMethod httpMethod, final String path, IResource resource) { ResourceReference reference = ResourceReference.of(path + "_" + httpMethod.name(), () -> resource); if (reference.canBeRegistered()) { application.getResourceReferenceRegistry().registerResourceReference(reference); } RestResourceMapper mapper = new RestResourceMapper(path, reference, httpMethod); application.mount(mapper); return mapper; }