Pages

Tuesday, May 28, 2013

CQ5/AEM how to create and use a custom taglib - part 3 use your tag

If you have not already completed part II, click here

The final step is to use your tag.

In the component of your choice, add the following to a jspx file:


<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns="http://www.w3.org/1999/xhtml"
          xmlns:jsp="http://java.sun.com/JSP/Page"
          xmlns:btes="http://btes.com.au/tagexample"
          version="2.1">
    <jsp:directive.include file="/apps/cqblueprints-example/components/global.jspx"/>
    <p>No tag left behind!</p>
    <btes:customTag content="Custom tag engaged" isHeading="true"/>
</jsp:root>

Now you should see the text "Custom tag engaged" rendered out as a heading. If you change the isHeading boolean to false, you should see it render as a paragraph.

Note that code complete should be fully functional with this example.

1 comment:

  1. Thank you Bayani,glad you are still coming up with all these great methods.Thank you very much for the update. I am doing website promotion, I hope your article will help me lot.

    ReplyDelete