I've got years of experience writing backing beans for Sling (aem)
components, but can't seem to get a simple JS backing working using the new
Javascript Use API.

All I want to do is print out a resource's children resources.

My JS backing bean:

use([], function () {
 
 var returnObj = {
        content: ""
    };
    
  var parent = resource.parent;
  var children = parent.getChildren();

  for (res in Iterator(children)) {
       returnObj.content += res.name;
  }
   
    return returnObj;
});

The contents of returnObj.content will be the word "undefined" repeated X
times, where X is the number of children nodes of parent. This tells me it
successfully iterates the Iterable once for each item in it, but it's
failing to give me a reference to a child. If I try res.getName() instead, I
get:

org.mozilla.javascript.EcmaError: TypeError: Cannot find default value for
object

In fact, every single variation I've tried for iterating that collection has
lead to that exact Exception.

It seems to me Rhino is getting in the way. Am I right? What is the
community consensus on use of the JS Use API? Is it production-ready and
stable? Is my problem a user-error? What limitations exist here? I was
planning on doing the same things in JS that I've always done in Java, which
is usually a lot of read/write operations on the JCR.



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/JS-Use-API-usability-or-limitations-tp4069490.html
Sent from the Sling - Users mailing list archive at Nabble.com.

Reply via email to