Thanks Bertrand & Felix, very helpful!
-- Juerg
On Mon, 2008-06-30 at 07:50 +0200, Bertrand Delacretaz wrote:
> Hi Juerg,
>
> On Sun, Jun 29, 2008 at 11:33 PM, Juerg Meier <[EMAIL PROTECTED]> wrote:
> > ...In JCR, I get an Item by absolute path the with Session.getItem(). How
> > is this done in Sling/ESP? There must be a predefined variable that
> > offers a getItem() or similar method, I assume?...
>
> The ScriptableNodeTest [1] class, and other classes in that test code
> tree, show many examples of how to use the javascript wrapper classes
> for Node, Property and other interfaces.
>
> The testGetSession() method in that class is probably what you need:
>
> assertEquals(
> "Root node found via node.session",
> "/",
> script.eval("node.session.getRootNode().getPath()", data)
> );
> assertEquals(
> "Root node found via node.getSession()",
> "/",
> script.eval("node.getSession().getRootNode().getPath()", data)
> );
> }
>
> It shows the two ways of getting at the Session, if you want to use
> the JCR API directly.
>
> You could also use resource.getResourceResolver() to get a
> ResourceResolver, and use its "Resource resolve(String absPath)"
> method, to stay in "resource space".
>
> -Bertrand
>
> [1]
> http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java?view=markup