[
https://issues.apache.org/jira/browse/SLING-8562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16882722#comment-16882722
]
Julian Sedding commented on SLING-8562:
---------------------------------------
[~fortuna] your script does get resolved, otherwise you would not see the error
you are seeing. It happens during script execution.
You are calling {{$\{currentNode.title\}}}, but there is no
{{javax.jcr.Node#getTitle()}} method. Try {{$\{currentNode.name\}}}
or{{$\{currentNode.path\}}}, which should both yield proper renderings, because
{{javax.jcr.Node#getName()}} and {{javax.jcr.Node#getPath()}} do exist.
Seemingly, there is some "intelligence" somewhere in the code (and possibly the
ESP implementation), that tries to make sense of the {{.title}} fragment and
attempts to find a child-node with a matching name. The FS Resource Provider is
primarily about providing resources, and on top of that it provides an
incomplete JCR emulation layer. You hit one of the parts that are incomplete;
to my knowledge there are no plans to provide a complete JCR emulation
implementation (I doubt that would even be possible).
I would recommend that you try writing your rendering scripts using the
{{Resource}} API instead. To get the title property of the current resource you
would write {{$\{resource.valueMap['title']\}}} or possibly even
{{$\{properties['title']\}}}. Note: I am not familiar with the ESP specifics,
but I would expect bindings for both {{resource}} and {{properties}} to be
present.
> Unable to resolve ESP scripts loaded from Filesystem Resource Provider
> ----------------------------------------------------------------------
>
> Key: SLING-8562
> URL: https://issues.apache.org/jira/browse/SLING-8562
> Project: Sling
> Issue Type: Bug
> Affects Versions: Scripting Core 2.0.46, File System Resource Provider
> 2.1.16
> Reporter: Ben Fortuna
> Priority: Major
>
> A simple test fails when trying to load a resource via Sling Filesystem
> Resource Provider.
> /content/sample/index.json:
> {code:java}
> {
> "sling:resourceType": "sample/page/index",
> "jcr:primaryType": "nt:unstructured",
> "title": "Sample App"
> }{code}
>
> /apps/sample/page/index/html.esp:
> {code:java}
> <html>
> <head><title>${currentNode.title}</title></head>
> <body></body>
> </html>{code}
>
> When both content and app are mounted via Filesystem Resource Provider config
> the following error results:
> {code:java}
> Internal Server Error (500)
> Exception:
> java.lang.UnsupportedOperationException
> at
> org.apache.sling.fsprovider.internal.mapper.jcr.FsNode.getNodes(FsNode.java:517)
> at
> org.apache.sling.scripting.javascript.wrapper.ScriptableNode.get(ScriptableNode.java:319)
> ...{code}
>
> Basically the javascript renderer tries to call `Node.getNodes(pattern)` to
> resolve the property `currentNode.title` but Filesystem Resource Provider
> doesnt support this method.
>
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)