Wednesday, April 5, 2017

How to create custom renderer for a file type in AEM

Use Case:

Honestly use cases for this could be different based on what you want to change in response for a specific file type. We will take an example where we want to add some custom header for a PDF file based on what author has added in property of that file. For example here if author has added a canonical url and no index property, then we want to add these property in response header of all pdf file request.

Prerequisite:

Note that in order to make these property available for asset, you have to override asset editor as well. One example of adding extra property to asset editor is here http://www.wemblog.com/2013/01/how-to-associate-cug-with-dam-asset-in.html

Implementation:
Key here is OptingServlet https://sling.apache.org/apidocs/sling7/org/apache/sling/api/servlets/OptingServlet.html which get invoked on every request. Here is one example

Note: Let me know if you have any question about implementation.

15 comments:

  1. Excellent and nice post. It will beneficial for everyone. Thanks for sharing such a wonderful post. Avail No 1 custom essay writing help UK from certified PhD writers. It is extremely helpful for me. You can email us at info@ukdissertationhelp.co.uk or Phone Number - 020 8144 9988

    ReplyDelete
  2. My Assignment Services is one such Online Assignment Help provider which provides a helping hand to all your academic related queries. They have a lot of professional experts who are skilful in giving you guidance and providing you with cheap assignment help services. You are free to contact their experts by visiting their website and get your pending presentations completed on the time. Given below are some of the steps that they follow while drafting your assignments. Many students see that Assignment Help UK experts are proficient in writing your assignments but no one wonders the reason behind it. However, students pursuing IT need to understand the concepts of Java because it holds down the concept of object oriented programming. The programming concepts are complex to understand and brings a havoc to students, that is why, My Assignment Services bring you our online assignment help services. Taking out some time to consider and contrast about what options that you have that you can include by writing them on a piece of paper. You can also contact some real time Deakin Referencing Generator experts to assist you with the following topics.

    ReplyDelete
  3. Thanks a lot for sharing this blog. I was searching for this topic for a while. Glad that I came across your blog. Great effort. Do share more.
    Cloud Computing Training in Chennai
    DevOps Training in Chennai
    Cloud computing Training
    RPA Training in Chennai
    AWS Training in Chennai
    Cloud Computing Courses in Chennai

    ReplyDelete
  4. You can take the help of assignments from AbAssignmentHelp. They provide assignment help services in the UK for more than a decade for universities and colleges.

    ReplyDelete
  5. Thanks a lot for sharing this blog. I was searching for this topic for a while. Glad that I came across your blog. Great effort. Do share more.

    UX Training in Chennai
    Python Training in Chennai
    Java Training in Chennai
    DevOps Training in Chennai

    ReplyDelete
  6. Wow its great post. I searched online many times these types of post. I am happy to find this wonderful blog. Thank you very much for sharing this blog with us. I must share this with others. If you Do my Assignment.

    ReplyDelete
  7. Thank you for sharing this informative post.MyAssignmenthelp is giving assignment help to students.we are already trusted by thousands of students who struggle to write their academic papers and also by those students who simply want paper writing service
    to save their time and make life easy.

    ReplyDelete
  8. Awesome content! You have shared an informative blog post. I am an online paper writing services expert and this piece of information helps me a lot.

    ReplyDelete