List of usage examples for org.apache.wicket.request.handler.resource ResourceRequestHandler respond
@Override public void respond(final IRequestCycle requestCycle)
From source file:fiftyfive.wicket.resource.MergedResourceRequestHandler.java
License:Apache License
public void respond(IRequestCycle requestCycle) { WebRequest origRequest = (WebRequest) requestCycle.getRequest(); // Explicitly set the last modified header of the response based on the last modified // time of the aggregate. Do this on the original response because our wrapped response // ignores the last modified headers contributed by each individual resource. WebResponse origResponse = (WebResponse) requestCycle.getResponse(); if (this.lastModified != null) { origResponse.setLastModifiedTime(this.lastModified); }/*from ww w . j a va 2 s.co m*/ try { // Make a special response object that merges the contributions of each resource, // but maintains a single set of headers. MergedResponse merged = new MergedResponse(origResponse); requestCycle.setResponse(merged); // Make a special request object that tweaks the If-Modified-Since header to ensure // we don't end up in a situation where some resources respond 200 and others 304. // Yes, calling RequestCycle#setRequest() is frowned upon so this is a bit of a hack. ((RequestCycle) requestCycle).setRequest(new MergedRequest(origRequest)); for (ResourceReference ref : this.resources) { ResourceRequestHandler handler = new ResourceRequestHandler(ref.getResource(), this.pageParameters); handler.respond(requestCycle); // If first resource sent 304 Not Modified that means all will. // We can therefore skip the rest. if (304 == merged.status) { break; } } } finally { // Restore the original request once we're done. We don't need to restore the // original response because Wicket takes care of that automatically. ((RequestCycle) requestCycle).setRequest(origRequest); } }
From source file:org.wicketstuff.jasperreports.EmbeddedJRReport.java
License:Apache License
/** * @see org.apache.wicket.IResourceListener#onResourceRequested() *//*from www. j a v a 2 s . c o m*/ public void onResourceRequested() { PageParameters pageParams = null; final Page page = findPage(); if (page != null) pageParams = page.getPageParameters(); ResourceRequestHandler reqh = new ResourceRequestHandler(resource, pageParams); reqh.respond(getRequestCycle()); }