Hi Daniel Am 20.08.2013 um 16:30 schrieb Daniel Platon:
> Hi everyone, > > Q: How can I determine the script used to render a certain resource type? > > Details: I'm trying to do this in a JSP page (for my sling-explorer > project) so that the user can see what script renders a certain type of > content (a resourceType that is). This is what I tried so far: > > 1. Obtain a reference to a ServletResolver service using > ServletResolver servletResolver = sling.getService(ServletResolver.class); > > 2. Ask the service to "resolve" the resource type: > Servlet servlet = > servletResolver.resolveServlet(resourceResolver,"myapp/mytype") The ServletResource.resolveServlet(ResovlerResolver, String) method takes a (relative) script path as its second argument not a resource type. And since there is no script with this relative path in the ResourceResovler's search path, you won't get it. The method finding a script would be ServletResource.resolveServlet(SlingHttpServletRequest) which requires you to have a request object, which exposes the Resource whose resource type is used (and whose super resource type is also used). The request object also provides the method and selectors helping to decide on the script. Regards Felix > > but this returns null. > > Everything is in place: the script is there, the resource renders correctly > (the script is in /apps/myapp/mytype/mytype.jsp), it's just that the > resolver returns null when asked to resolve a script. > > Is there another way (perhaps... the right way :) ) to do this? > > Thank you and have a good day. > ___________________________ > Daniel Platon
