use of org.apache.wicket.feedback.FeedbackDelay in project wicket by apache.
the class PageAndComponentProvider method getComponent.
@Override
public IRequestableComponent getComponent() {
if (component == null) {
IRequestablePage page = getPageInstance();
component = page != null ? page.get(componentPath) : null;
if (component == null) {
// make sure this page instance was just created so the page can be stateless
if (page.isPageStateless()) {
Page p = (Page) page;
p.internalInitialize();
// preparation of feedbacks is delayed into the render phase
try (FeedbackDelay delay = new FeedbackDelay(p.getRequestCycle())) {
p.beforeRender();
p.markRendering(false);
// note: no invocation of delay.onBeforeRender()
}
component = page.get(componentPath);
}
}
}
if (component == null) {
throw new ComponentNotFoundException("Could not find component '" + componentPath + "' on page '" + getPageClass());
}
return component;
}
use of org.apache.wicket.feedback.FeedbackDelay in project wicket by apache.
the class PartialPageUpdate method writeComponents.
/**
* Processes components added to the target. This involves attaching components, rendering
* markup into a client side xml envelope, and detaching them
*
* @param response
* the response to write to
* @param encoding
* the encoding for the response
*/
private void writeComponents(Response response, String encoding) {
componentsFrozen = true;
List<Component> toBeWritten = new ArrayList<>(markupIdToComponent.size());
// delay preparation of feedbacks after all other components
try (FeedbackDelay delay = new FeedbackDelay(RequestCycle.get())) {
for (Component component : markupIdToComponent.values()) {
if (!containsAncestorFor(component)) {
if (prepareComponent(component)) {
toBeWritten.add(component);
}
}
}
// .. now prepare all postponed feedbacks
delay.beforeRender();
}
// write components
for (Component component : toBeWritten) {
writeComponent(response, component.getAjaxRegionMarkupId(), component, encoding);
}
if (header != null) {
RequestCycle cycle = RequestCycle.get();
// some header responses buffer all calls to render*** until close is called.
// when they are closed, they do something (i.e. aggregate all JS resource urls to a
// single url), and then "flush" (by writing to the real response) before closing.
// to support this, we need to allow header contributions to be written in the close
// tag, which we do here:
headerRendering = true;
// save old response, set new
Response oldResponse = cycle.setResponse(headerBuffer);
headerBuffer.reset();
// now, close the response (which may render things)
header.getHeaderResponse().close();
// revert to old response
cycle.setResponse(oldResponse);
// write the XML tags and we're done
writeHeaderContribution(response);
headerRendering = false;
}
}
use of org.apache.wicket.feedback.FeedbackDelay in project wicket by apache.
the class Page method renderPage.
@Override
public void renderPage() {
// page id is frozen during the render
final boolean frozen = setFreezePageId(true);
try {
++renderCount;
// delay rendering of feedbacks after all other components
try (FeedbackDelay delay = new FeedbackDelay(getRequestCycle())) {
beforeRender();
delay.beforeRender();
}
markRendering(true);
render();
} finally {
setFreezePageId(frozen);
}
}
Aggregations