Leiste mit Community-Erfolgen erweitern.

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

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

Author tag throgh component and retrive on Page

Avatar

Level 5

Hi Team, 

I'm trying to create a component which has the resource type as 

cq/gui/components/coral/common/form/tagfield

I want to retrive this component values on page like text filed. Is there a way to do this. Getting tag values from component not from page properties. 

 

1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Community Advisor

Hi @Tessa_learner1 

In your sling model you can use TagManager API to read tag values.

@SlingObject
private ResourceResolver resourceResolver;
@ValueMapValue
private String tagName; //tag field name from your component dialog
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
Tag tag = tagManager.resolve(tagName);
String tagTitle = tag.getTitle();
String tagId = tag.getId(); 

More details on TagManager API can be found in below javadoc.

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/tagging/Ta...

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/tagging/Ta...

 

Lösung in ursprünglichem Beitrag anzeigen

6 Antworten

Avatar

Korrekte Antwort von
Community Advisor

Hi @Tessa_learner1 

In your sling model you can use TagManager API to read tag values.

@SlingObject
private ResourceResolver resourceResolver;
@ValueMapValue
private String tagName; //tag field name from your component dialog
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
Tag tag = tagManager.resolve(tagName);
String tagTitle = tag.getTitle();
String tagId = tag.getId(); 

More details on TagManager API can be found in below javadoc.

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/tagging/Ta...

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/tagging/Ta...

 

Avatar

Community Advisor

Do you want to read them from the component and display on the page as text ?

If that is the case which one do you want to display is it tagname or tagId ?

Can you explain more on this ?

Avatar

Level 5

Hi @Mani_kumar_ Thanks for your response. Yes I want to read tags through component and I just want to display only the name of the tag on page. 

Avatar

Community Advisor

Hi @Tessa_learner1 

If that is the case as mentioned by @salamswapnil use Tagmanager API read name from the parsed Tag object it should solve your problem.

 

Avatar

Level 1

iamsumansourav_0-1684322393203.png

How to get tag from tagging. I want industry, sector and country tag name How I'll get, How I write sling model. @arunpatidar  @BrianKasingli 

Avatar

Community Advisor

Hi @iamsumansourav 
@salamswapnil has already provided the code sample, to get tag name from tag id.

Arun Patidar

AEM LinksLinkedIn