Hi,

Amit Snyderman schrieb:
> Hey there, curious as to how to accomplish the following:
> 
> (1) Create a temporary resource that doesn't get created in the JCR /
> map to a node
> (2) Evaluate and include a script against the temporary resource
> 
> Thinking I may be on the right path with:
> 
>     ResourceMetadata meta = new ResourceMetadata();
>     meta.setResolutionPath("synthetic");

This is not, strictly speaking, required.

> 
>     SyntheticResource r = new SyntheticResource(
>         slingRequest.getResourceResolver(),
>         meta,
>         "path/to/resource/type"
>     );
> 
>     slingRequest.getRequestDispatcher(r, new
> RequestDispatcherOptions()).include(slingRequest, slingResponse);
> 
> Any way to add properties to the `SyntheticResource`?

What do you mean by "add properties" ?

If you are thinking about supporting the adaptTo method, you might
create your own extension of the SyntheticResource:

   Resource r = new SyntheticResource(...) {
      public <T> T adapTo(Class<T> type) {
          if (type == Map.class) {
             return ...someMap...
          }
          return super.adaptTo(type);
      }
   }

> Is there a better way to accomplish something similar?

In JSP you don't really need to explicitly create a synthetic resource
and can just do

    <sling:include path="/the/path" resourceType="the/resource/type" />

which takes care of everything.

Regards
Felix
> 
> thanks,
> Amit
> 

Reply via email to