Hi,
I've been looking a way to customize Asset Finder in Touch UI based to add custom tabs for references we've created for our projects. All I could find out from out of box functionality is if we hit this URL given below from our localhost:
It displays html content. And,if hit with .json extension, it displays json.
So, how can we create our custom servlet which display html content on hitting with .html extension and json on hitting with .json extension.
Like, on hitting above URL with .html extension, it displays image with some text properties. And, on hitting with .json, it displays properties key-value pairs.
Solved! Go to Solution.
Views
Replies
Total Likes
As mentioned by Jitendra, we can Script resolution to achieve this.
Reference link:- https://www.youtube.com/watch?v=ySw7vE1hdT8
How Sling resolution is done in AEM:- http://www.aemcq5tutorials.com/tutorials/sling-resource-resolution-aem/
//
If you’ve worked on AEM much, you should have at least been exposed to this diagram:
There’s a lot going on here, but I’m just going to focus on query parameters, selectors, and suffixes.
Link:- http://aempodcast.com/2013/apache-sling/sling-request-suffixes-explained/#.VpxqJvl97RY
Option 2:- Using Sling Servlet
//
Instead of making ajax call to the path in the servlet, you make an ajax call to the component. In case you want the servlet to work with resourceType the servlet should have an additional configuration for extensions property (sling.servlet.extensions).This configuration let's you run a servlet in context of a resource(of a particular resourceType) instead of a global one.
Let me explain with an example. Consider a page content/home.html with a foo component (resourceType="/apps/someproject/components/foo) at path /par/foo . Normally on a page the component will be requested with .html selector and the resource will be rendered by the default script (foo.jsp). Let's add a servlet with the following annotation
@SlingServlet( name="Weatherservlet", extensions = "pdf", resourceType="someproject/components/foo", methods="GET", metatype=true) which will give pdf representation of the resource.
A GET request to /content/home/jcr:content/par/foo.pdf will be handled by the servlet instead offoo.jsp.
request.getResource() inside the servlet's doGet will return the component resource.
path configuration will override the resourceType configuration.
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Hi Himanshu,
Here is the article which talks about SlingServlet.
http://blogs.adobe.com/aaa/2012/09/cq-tips-and-tricks-1-how-to-define-a-slingservlet-cq5-5-5-6.html
There are multiple ways to achieve it. One option is, build a servlet which have html &
The second option could be
https://sling.apache.org/documentation/the-sling-engine/url-to-script-resolution.html
Jitendra
Views
Replies
Total Likes
As mentioned by Jitendra, we can Script resolution to achieve this.
Reference link:- https://www.youtube.com/watch?v=ySw7vE1hdT8
How Sling resolution is done in AEM:- http://www.aemcq5tutorials.com/tutorials/sling-resource-resolution-aem/
//
If you’ve worked on AEM much, you should have at least been exposed to this diagram:
There’s a lot going on here, but I’m just going to focus on query parameters, selectors, and suffixes.
Link:- http://aempodcast.com/2013/apache-sling/sling-request-suffixes-explained/#.VpxqJvl97RY
Option 2:- Using Sling Servlet
//
Instead of making ajax call to the path in the servlet, you make an ajax call to the component. In case you want the servlet to work with resourceType the servlet should have an additional configuration for extensions property (sling.servlet.extensions).This configuration let's you run a servlet in context of a resource(of a particular resourceType) instead of a global one.
Let me explain with an example. Consider a page content/home.html with a foo component (resourceType="/apps/someproject/components/foo) at path /par/foo . Normally on a page the component will be requested with .html selector and the resource will be rendered by the default script (foo.jsp). Let's add a servlet with the following annotation
@SlingServlet( name="Weatherservlet", extensions = "pdf", resourceType="someproject/components/foo", methods="GET", metatype=true) which will give pdf representation of the resource.
A GET request to /content/home/jcr:content/par/foo.pdf will be handled by the servlet instead offoo.jsp.
request.getResource() inside the servlet's doGet will return the component resource.
path configuration will override the resourceType configuration.
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Views
Likes
Replies