Thanks for your help Felix!

Felix Meschberger wrote:
Hi Erik,

Am Montag, den 21.04.2008, 13:46 +0200 schrieb Erik Buene:
Hi

I am experimenting with using xslt transformations on sling by using my own renderer servlet. Since the system we are building will require a type of wysiwig template builder (building templates without writing code) we will need a set of pre-written template fragments.

For including these fragments I'm using req.getRequestDispatcher("/path/to/content.fragmentId.myExtention").include(req, resp). This works fine. However not all fragments really need any content (for instance a search form). Therefore I would like to be able to include something without the overhead of reading content from the repository, a sort of "dummy content object".

Is this possible?

Yes, we call this a SyntheticResource. You create the SyntheticResource
with the current ResourceResolver as well as the path and type of the
synthetic resource. When using the predefined object "sling" which is a
SlingScriptHelper instance, you may even do it easier. Given you have a
path of "/sample/path" and want to synthesize a resource of type
"sample/type", you may do:

    sling.include("/sample/path", "sample/type");

This works in all scripting languages, except JSP (for the moment,
because for JSP the sling object is not predefined yet).

The same question would also apply for ".esp" or other script types when using includes. How do you go about including a script that does not need specific content from the repository.

You can - at the moment - do static source include on in JSP. For ECMA
(.esp) and other scripting language the only way to include content is
by means of the RequestDispatcher include.

We are in fact considering to add support for static script include also
in ECMA to allow for shared code.

Hope this helps.

Regards
Felix





--
==================

Erik Buene
Senior Developer
Idium AS

Reply via email to