コミュニティアチーブメントバーを展開する。

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

この会話は、活動がないためロックされています。新しい投稿を作成してください。

解決済み

How to read tag titles for tags entered in tagfield?

Avatar

Level 4

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.

1 受け入れられたソリューション

Avatar

正解者
Community Advisor

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
}
  •  In the above snippet, referencing the InheritanceValueMap and getting resource resolver from request. You can also take resource resolver with System User.
  • If you have a single tag you can directly resolve it

 

Hope this could help you !!!

Regards

Shiv

Shiv Prakash

元の投稿で解決策を見る

4 返信

Avatar

正解者
Community Advisor

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
}
  •  In the above snippet, referencing the InheritanceValueMap and getting resource resolver from request. You can also take resource resolver with System User.
  • If you have a single tag you can directly resolve it

 

Hope this could help you !!!

Regards

Shiv

Shiv Prakash

Avatar

Level 4

Thanks a lot. 

Avatar

Level 4

@Shiv_Prakash_Patel here for tags added in page properties I can access with page properties inheritance value map but can you help me with how can I access all tags being added in tagfield added in dialog of my component?

Avatar

Community Advisor

Hi @Manasi29 ,

You can use ValueMap to read the tag value from the custom component. In the above case just replace the InheritanceValueMap with the ValueMap.

@Inject
private ValueMap valueMap;

 

Shiv Prakash