Sightly / WCMUse error.
Hi, I'm trying to create a WCMUse java object at the component level to use with sightly, and I keep getting the following error:
org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: No use provider could resolve identifier: AEMUser
The idea is to wrap the jackrabbit user class for use by sightly, my company does a lot with security groups and prefer to do things on the code level vs the author targeting level (our authors don't understand targeting)
Anyway, here is the class that wraps the jackrabbit User class:
package apps.AEMUPGRADE.components.aemUser; import org.apache.jackrabbit.api.security.user.User; import org.apache.jackrabbit.api.security.user.Group; import com.adobe.cq.sightly.WCMUse; public class AEMUser extends WCMUse{ private String username; private User user; public AEMUser(String username){ this.username = username; } @Override public void activate() throws Exception { username = get("username", String.class); user = getResource().adaptTo(User.class); } public User getUser(){ return user; } public String getUsername(){ return username; } public java.util.Iterator<Group> getUserGroups(){ try{ if(user!=null){ return user.memberOf(); } }catch(javax.jcr.RepositoryException jre){ //Hold off for now } return null; } }I will likely move this into a bundle but just wanted to get it working first.
Here is my sightly code:
<div class="${properties.cssClass}"> Hello, ${request.remoteUser} </div> <p>You belong to the following groups</p> <ul data-sly-use.aemUser="AEMUser"> <li>${user.username}</li> <li> <ul data-sly-list.child="${user.userGroups}"> <li>${childList.index}:${child.iD}</li> </ul> </li> </ul>And here are the paths:
/apps/AEMUPGRADE/components/aemUser/aemUser.html
/apps/AEMUPGRADE/components/aemUser/AEMUser.java
I followed all the examples to make this, not sure what I did wrong, I keep going over and over it but it doesn't seem to want to register AEMUser as a sightly object.
Am I missing something?