use of org.apache.tapestry5.BooleanHook in project tapestry-5 by apache.
the class JavaScriptModule method exposeJavaScriptSupportForFullPageRenders.
/**
* Adds page render filters, each of which provides an {@link org.apache.tapestry5.annotations.Environmental}
* service. Filters
* often provide {@link org.apache.tapestry5.annotations.Environmental} services needed by
* components as they render.
* <dl>
* <dt>JavascriptSupport</dt>
* <dd>Provides {@link JavaScriptSupport}</dd>
* </dl>
*/
@Contribute(MarkupRenderer.class)
public void exposeJavaScriptSupportForFullPageRenders(OrderedConfiguration<MarkupRendererFilter> configuration, final JavaScriptStackSource javascriptStackSource, final JavaScriptStackPathConstructor javascriptStackPathConstructor, final Request request) {
final BooleanHook suppressCoreStylesheetsHook = createSuppressCoreStylesheetHook(request);
MarkupRendererFilter javaScriptSupport = new MarkupRendererFilter() {
public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) {
DocumentLinker linker = environment.peekRequired(DocumentLinker.class);
JavaScriptSupportImpl support = new JavaScriptSupportImpl(linker, javascriptStackSource, javascriptStackPathConstructor, suppressCoreStylesheetsHook);
environment.push(JavaScriptSupport.class, support);
renderer.renderMarkup(writer);
environment.pop(JavaScriptSupport.class);
support.commit();
}
};
configuration.add("JavaScriptSupport", javaScriptSupport, "after:DocumentLinker");
}
use of org.apache.tapestry5.BooleanHook in project tapestry-5 by apache.
the class JavaScriptModule method exposeJavaScriptSupportForPartialPageRender.
/**
* Contributes {@link PartialMarkupRendererFilter}s used when rendering a
* partial Ajax response.
* <dl>
* <dt>JavaScriptSupport
* <dd>Provides {@link JavaScriptSupport}</dd>
* </dl>
*/
@Contribute(PartialMarkupRenderer.class)
public void exposeJavaScriptSupportForPartialPageRender(OrderedConfiguration<PartialMarkupRendererFilter> configuration, final JavaScriptStackSource javascriptStackSource, final JavaScriptStackPathConstructor javascriptStackPathConstructor, final Request request) {
final BooleanHook suppressCoreStylesheetsHook = createSuppressCoreStylesheetHook(request);
PartialMarkupRendererFilter javascriptSupport = new PartialMarkupRendererFilter() {
public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer) {
IdAllocator idAllocator;
if (request.getParameter(InternalConstants.SUPPRESS_NAMESPACED_IDS) == null) {
String uid = Long.toHexString(System.nanoTime());
String namespace = "_" + uid;
idAllocator = new IdAllocator(namespace);
} else {
// When suppressed, work just like normal rendering.
idAllocator = new IdAllocator();
}
DocumentLinker linker = environment.peekRequired(DocumentLinker.class);
JavaScriptSupportImpl support = new JavaScriptSupportImpl(linker, javascriptStackSource, javascriptStackPathConstructor, idAllocator, true, suppressCoreStylesheetsHook);
environment.push(JavaScriptSupport.class, support);
renderer.renderMarkup(writer, reply);
environment.pop(JavaScriptSupport.class);
support.commit();
}
};
configuration.add("JavaScriptSupport", javascriptSupport, "after:DocumentLinker");
}
Aggregations