Description
Actually the Dispatch servlet, which serves content in Magma, operates in two distinct ways :
- If result is a Producer, stream it to output. This is the case for resources.
- If result is an HtmlProducer, pass it to a template, which will take care of aggregating stuff around it and use an URLRewritingStream for proper URL rewriting.
This is nice, but limitating. There are situations where :
- We want to serve an html fragment having the advantage of URL rewriting, but not having a template around.
- We want to use a different template, and force it no matter what
- We want to use a different template and eventually different post processing.
A use case for the first situation is quite simple : an html frameset for example, there must be URL rewriting but no template around it. Another one, serving an HTML fragment as the result on an AJAX call, we want the fragment as it would appear inside the template, but without all the template around.
For the second situation, a good use case is a print template. There are already a number of methods to set the template, using the Templatable interface, but the innermost setting takes precedence over the outmost, whle in this case the opposite should happen.
The third situation is for advanced stuff, like HTML to PDF generation (perfectly possible with XSLT translating to XSL-FO, or using CSS 3 and a postprocessor) or again more complex Ajax interactions.