Customizing 'Edit Tag' Dialog and Retrieving Custom Field in Code | Community
Skip to main content
toshbot
Level 2
November 16, 2016
Solved

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

  • November 16, 2016
  • 5 replies
  • 2114 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Peter_Puzanovs

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

5 replies

smacdonald2008
Level 10
November 16, 2016

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

toshbot
toshbotAuthor
Level 2
November 16, 2016

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.

Peter_Puzanovs
Community Advisor
Peter_PuzanovsCommunity AdvisorAccepted solution
Community Advisor
November 16, 2016

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

toshbot
toshbotAuthor
Level 2
November 16, 2016

This worked exactly as described! Thank you!

July 14, 2017

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?