Hi Felix, > > > 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.
I am not exactly a velocity expert, but I tried this and had no success so far. But I also think that having to "cast" (sort of) a resource into a node in a script is a bit weird. Especially, if you consider that resource.nodeworks in esp's. Could we not just get the node as an object right away? I am aware that this has been discussed before, but I do not see any advantages of abstraction lost if the node object is available to the scripts if the resource in question is actually a node. The script needs to "know" it handles nodes anyway. WDYT? Michael