April 3, 2020
Estimated Post Reading Time ~

How to create and use a custom taglib - part 3 use your tag

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.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.