ResourceResolver using Javascript-Use API?
Hi there,
I am trying to convert my components over to the HTL/Sightly instead of JSP, and I'm running into a road block.
I'd prefer to do the HTL using Javascript-Use API instead of Java-Use because I am more familiar with JS.
My new JS code below errors out:
"Can't find method com.myproject.aem.util.GlobalUtils.userCanReadRedirectTarget(java.lang.Class,org.mozilla.javascript.Undefined).
Any ideas why?
In the old JSP, I have this:
boolean isUnlocked = GlobalUtils.userCanReadRedirectTarget(resourceResolver, linkPath);
if(!isUnlocked) {
// do something here
}
In the new JS file, I have this:
"use strict";
var GlobalUtils = Packages.com.myproject.aem.util.GlobalUtils;
var ResourceResolver = Packages.org.apache.sling.api.resource.ResourceResolver;
use(function() {
var linkPath = properties.get("linkPath");
var isUnlocked = GlobalUtils.userCanReadRedirectTarget(ResourceResolver, linkPath);
return {
isUnlocked: isUnlocked
};
});
Thanks in advance!