/** * @see org.apache.wicket.behavior.AbstractBehavior#onException(org.apache.wicket.Component, * java.lang.RuntimeException) */ public void onException(Component component, RuntimeException exception) { if (webResponse != null) { final RequestCycle requestCycle = RequestCycle.get(); requestCycle.setResponse(webResponse); } }
/** * @see org.apache.wicket.behavior.AbstractBehavior#onException(org.apache.wicket.Component, * java.lang.RuntimeException) */ @Override public void onException(Component component, RuntimeException exception) { if (webResponse != null) { final RequestCycle requestCycle = RequestCycle.get(); requestCycle.setResponse(webResponse); } }
private void run(Runnable runnable, Response response) { if (AjaxRequestTarget.get() != null) { // we're in an ajax request, so we don't filter and separate stuff.... runnable.run(); return; } Response original = RequestCycle.get().setResponse(response); try { runnable.run(); } catch (RuntimeException ex) { throw ex; } finally { RequestCycle.get().setResponse(original); } }
public CharSequence execute() { final int originalStreamPos = stream.getCurrentIndex(); final Response original = cycle.getResponse(); final StringResponse buffer = new StringResponse(); cycle.setResponse(buffer); try { executeInsideBufferedZone(); return buffer.getBuffer(); } finally { cycle.setResponse(original); stream.setCurrentIndex(originalStreamPos); } }
@Override protected void onComponentTagBody(MarkupStream markupStream, final ComponentTag openTag) { MarkupStream originalMarkupStream = getMarkupStream(); int beginOfBodyIndex = originalMarkupStream.getCurrentIndex(); Response response = new StringResponse(); RequestCycle requestCycle = getRequestCycle(); Response webResponse = requestCycle.setResponse(response); try { super.onComponentTagBody(markupStream, openTag); webResponse.write(response.toString()); } catch (WicketRuntimeException ex) { log.error("runtime plugin failure", ex); // this is a plugin, don't let the entire UI fail because of it failing markupStream.setCurrentIndex(beginOfBodyIndex); markupStream.skipToMatchingCloseTag(openTag); } finally { requestCycle.setResponse(webResponse); } }
/** * @see org.apache.wicket.behavior.IBehavior#onComponentTag(org.apache.wicket.Component, * org.apache.wicket.markup.ComponentTag) */ public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("xmlns:wicket", "http://wicket.apache.org"); final RequestCycle requestCycle = RequestCycle.get(); // Temporarily replace the web response with a String response webResponse = requestCycle.getResponse(); // Create a new response object final Response response = newResponse(); if (response == null) { throw new IllegalStateException("newResponse() must not return null"); } // and make it the current one requestCycle.setResponse(response); }
Response oldResponse = RequestCycle.get().setResponse(encodingHeaderResponse); encodingHeaderResponse.reset(); RequestCycle.get().setResponse(oldResponse);
getRequestCycle().setResponse(response); getRequestCycle().setResponse(webResponse);
getRequestCycle().setResponse(response); getRequestCycle().setResponse(webResponse);
/** * @see org.apache.wicket.behavior.AbstractBehavior#onRendered(org.apache.wicket.Component) */ public void onRendered(final Component component) { final RequestCycle requestCycle = RequestCycle.get(); try { Response response = requestCycle.getResponse(); // Transform the data CharSequence output = transform(component, response.toString()); webResponse.write(output); } catch (Exception ex) { throw new WicketRuntimeException("Error while transforming the output: " + this, ex); } finally { // Restore the original response object requestCycle.setResponse(webResponse); } }
/** * @see org.apache.wicket.behavior.AbstractBehavior#onRendered(org.apache.wicket.Component) */ @Override public void onRendered(final Component component) { final RequestCycle requestCycle = RequestCycle.get(); try { Response response = requestCycle.getResponse(); // Transform the data CharSequence output = transform(component, response.toString()); webResponse.write(output); } catch (Exception ex) { throw new WicketRuntimeException("Error while transforming the output: " + this, ex); } finally { // Restore the original response object requestCycle.setResponse(webResponse); } }
getRequestCycle().setResponse(response); getRequestCycle().setResponse(orgResponse);
Response oldResponse = RequestCycle.get().setResponse(encodingHeaderResponse); RequestCycle.get().setResponse(oldResponse);
getRequestCycle().setResponse(response); getRequestCycle().setResponse(orgResponse);
/** * @see org.apache.wicket.behavior.AbstractBehavior#beforeRender(org.apache.wicket.Component) */ @Override public void beforeRender(Component component) { super.beforeRender(component); final RequestCycle requestCycle = RequestCycle.get(); // Temporarily replace the web response with a String response webResponse = requestCycle.getResponse(); // Determine encoding final String encoding = Application.exists() ? Application.get() .getRequestCycleSettings() .getResponseRequestEncoding() : "UTF-8"; // Set content type based on markup type for page webResponse.setContentType("text/" + getMarkupType(component) + "; charset=" + encoding); // Create a new response object final Response response = newResponse(); if (response == null) { throw new IllegalStateException("newResponse() must not return null"); } // and make it the current one requestCycle.setResponse(response); }
getRequestCycle().setResponse(response); getRequestCycle().setResponse(webResponse);
RequestCycle.get().setResponse(encodingBodyResponse); RequestCycle.get().setResponse(originalResponse);
try container.getRequestCycle().setResponse(NullResponse.getInstance()); htmlContainer.autoAdd(headerPart, null); container.getRequestCycle().setResponse(response);
try container.getRequestCycle().setResponse(NullResponse.getInstance()); htmlContainer.autoAdd(headerPart, null); container.getRequestCycle().setResponse(response);
Response oldResponse = RequestCycle.get().setResponse(encodingHeaderResponse); RequestCycle.get().setResponse(oldResponse);