Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Customizing 'Edit Tag' Dialog and Retrieving Custom Field in Code

Avatar

Level 2

I have a two part question. One is about approach, and the other is just a question.

1. I have managed to customize the 'Edit Tag' dialog by copying /cq/tagging/widgets from /libs to /apps. Then I changed TagAdmin.Actions.js to add a new field. I am able to add values and persist them. Is this the correct approach for customizing this dialog?

2. Now, I'd like to fetch this new property in code. The AEM java Tag API does not have any generic "get" method that can you can use to fetch any property of desire. Would I need to use the Node class instead? Or is there any way I can do this using the Tag API.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi Toshbot,

Tag[1] can be Adapted to Resource

Resource resource = tag.adaptTo(Resource.class); String customProperty = resource.getValueMap().get("customProperty", StringUtils.EMPTY);

Via resource you should be able to retrieve any custom property you have set.

[1] https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/tagging/Tag.html

You can see what adapts to what on your local instance[2]

[2] http://localhost:4502/system/console/adapters

Regards,

Peter

View solution in original post

5 Replies

Avatar

Level 10

FOr 1 - yes you used overlay approach, which is the correct way. 

See this artilce that shows how to work with HTL and Tag Manager API. It also shows you how to get tags from a dialog: 

https://helpx.adobe.com/experience-manager/using/tagmanager-api-htl.html

Avatar

Level 2

Hi smacdonald2008,

Thank you so much for your response! I skimmed the article you linked, and we are doing something almost identical to get the tags (building a query, using TagManager, etc).

I still don't know how I'd extract my custom property from the tag though... There is no "getProperty" method available to the Tag class.

Avatar

Correct answer by
Community Advisor

Hi Toshbot,

Tag[1] can be Adapted to Resource

Resource resource = tag.adaptTo(Resource.class); String customProperty = resource.getValueMap().get("customProperty", StringUtils.EMPTY);

Via resource you should be able to retrieve any custom property you have set.

[1] https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/tagging/Tag.html

You can see what adapts to what on your local instance[2]

[2] http://localhost:4502/system/console/adapters

Regards,

Peter

Avatar

Level 2

This worked exactly as described! Thank you!

Avatar

Level 1

i want to add path field to the create tag console. can u share me where to add the js. is it mandatory to add in js?