So to answer my question, I have used approach as provided in Will's article:
http://www.tridiondeveloper.com/cleaning-and-extending-dynamic-linking
So I extended TagRenderer
class and provided implementation in doEndTag()
. It works now.
public String doEndTag(Tag tag, StringBuffer stringBuffer, TransformContext transformContext, OutputDocument outputDocument)
throws TCDLTransformerException {
String type = tag.getAttribute("type", "");
String tcm = tag.getAttribute("tcm", "");
String attributes = tag.getAttribute("attributes", "");
String parameters = tag.getAttribute("parameters", "");
String anchor = tag.getAttribute("anchor", "");
String text = tag.getAttribute("text", "");
String urlonly = tag.getAttribute("urlOnly", "");
String link = "";
if (type.equalsIgnoreCase("page")) {
link = generatePageLink(tcm, attributes, parameters, anchor, text, urlonly);
} else if (type.equalsIgnoreCase("component")) {
link = generateComponentLink(tcm, attributes, parameters, anchor, text, urlonly);
}
if (StringUtils.isEmpty(link)){
if(urlonly!=null && urlonly.length()==0) {
link = "<!--" + tag.toString() + "-->";
}
else if(urlonly!=null && urlonly.length()!=0){
link=tcm;
}
}
link = link.replaceAll("/index.html", "/");
stringBuffer.append(link);
return stringBuffer.toString();
}