Am Donnerstag, den 14.02.2008, 16:11 +0100 schrieb Michael Marth:
> Hi,
> 
> I am just looking at the various scripting engines and ran into some probs.
> Maybe someone can help?
> 
> Velocity
> -----------
> I have installed the velocity bundle and want to do the first test in
> Bertrand's 15min tutorial with a velocity script. Saving this as
> html.vltworks OK:
> <html>
> <body>
>     $resource.getResourceType() <br>
>     $resource.getPath()
> </body>
> </html>
> I get something like:
> foo/bar
> /content/mynode
> 
> But if I try to access something like $resource.node (which I would have
> expected) Velocity does not recognize the expression. How do I get to the
> node? Do I have the wrong syntax? I looked at the src of JcrNodeResource and
> expected to be able to use something like .node, .getNode() or similar.

I do not exactly know, how velocity maps Java objects. But a resource is
definitely a Resource and by conincidence a JcrNodeResource. In
addition, the JcrNodeResource.getNode() method is not public and not
part of the API.

When you want to access the node of a resource you will have to adapt
the Resource to the Node class, something like:

     $resource.adaptTo(Node.class);

But I am not exactly sure about the exact syntax.

> 
> Freemarker
> ----------------
> Almost the same as velocity. If I save this as html.ftl
> <html><body>
>     ${resource.resourceType} <br>
>     ${resource.path}
> </body></html>
> 
> This works, but this
> 
> <html><body>
> ${resource.node}
> </body></html>

Same here: node is neither a property nor is there a public getter. Use
the adaptTo method.

> 
> Gives an exception: Expression resource.node is undefined on line 3, column
> 3 in /apps/foo/bar/html.ftl. The problematic instruction: ---------- ==> ${
> resource.node} [on line 3, column 1 in /apps/foo/bar/html.ftl] ----------
> Java backtrace for programmers: ----------
> freemarker.core.InvalidReferenceException: Expression resource.node is
> undefined on line 3, column 3 in /apps/foo/bar/html.ftl
> 
> Ruby
> -------
> Saving anything as html.erb gives me an exception when I do a request like
> above. I installed the scripting bundle just like for velocity and
> freemarker. The console says things are fine. The exception is:
> 
> org/jruby/runtime/callback/InvocationCallback (500)
> The requested URL /content/mynode.html resulted in an error in Sling Default
> Error Handler Servlet.
> Exception:
> java.lang.NoClassDefFoundError:
> org/jruby/runtime/callback/InvocationCallback
> 
> Is there additional installation work to be done for Ruby?

Not sure, what the problem might be here... Could it be that the
bundling is incomplete ? Paddy do you have an idea ?

Regards
Felix

Reply via email to