Solved
How to read tag titles for tags entered in tagfield?
I have a tagfield included in my dialog. I want to print the titles for the tags being added in tagfield how can I achieve that? A code snippet for the same will be really useful.
I have a tagfield included in my dialog. I want to print the titles for the tags being added in tagfield how can I achieve that? A code snippet for the same will be really useful.
Hi @manasi29 ,
Here is a code snippet of reading a tag from the page properties dialog, Similarly you can modify the code for the custom component dialog as well in the sling model.
//Getting all Tags from InheritanceValueMap
String[] allTags = pageProperties.get("cq:Tags", String[].class);
TagManager tagManager = request.getResourceResolver().adaptTo(TagManager.class);
for (String tags : allTags) {
Tag tag = tagManager.resolve(tags);
String tagTitle = tag.getTitle();
String tagName = tag.getName();
//Custom Code
}
Hope this could help you !!!
Regards
Shiv
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.