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.

7 comments:

  1. The share your really gives us excitement. Thanks for your sharing. If you feel tired at work or study try to participate in our games to bring the most exciting feeling. Thank you!
    hotmail login | red ball | 192.168.1.1

    ReplyDelete
  2. Wow! You are doing good job dude. and this helpful for me and hope others also. Thanks!

    ReplyDelete
  3. Thank you for the instruction! This does help me a lot!
    json formatter
    spanish to english

    ReplyDelete
  4. This is a wonderful post. I enjoyed the information lot. I will bookmark this page. Thanks for sharing this information.
    starfall | barney | abcya

    ReplyDelete
  5. Ward vs Kovalev 2 was a highly anticipated professional boxing superfight for the unified WBA, IBF, and WBO light heavyweight titles. Andre Ward vs Sergey Kovalev bout was held on November 19, 2016, at the T-Mobile Arena in Las Vegas, Nevada. The event was televised on HBO Pay-per-view. Ward won the fight by unanimous decision to take the titles.





    Ward vs Kovalev record: Kovalev (30-1-1, 26 KOs) looks to get revenge against Ward (31-0, 15 KOs) in a light heavyweight title contest.



    So, Don't miss Watch Their last Ward vs Kovalev fight was also in Las Vegas, but at the T-Mobile Center.

    ReplyDelete