Customizing 'Edit Tag' Dialog and Retrieving Custom Field in Code | Community
Skip to main content
toshbot
Level 2
Nov 16, 2016 6:42 PM UTC
Solved

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

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.
Peter_Puzanovs
Peter_PuzanovsAccepted solution
New Participant
Nov 16, 2016 9:16 PM UTC

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

New Participant
Jul 14, 2017 5:18 PM UTC

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?

Translate
toshbot
toshbotAuthor
Level 2
Nov 16, 2016 10:03 PM UTC

This worked exactly as described! Thank you!

Translate
Peter_Puzanovs
Peter_PuzanovsAccepted solution
New Participant
Nov 16, 2016 9:16 PM UTC

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

Translate
toshbot
toshbotAuthor
Level 2
Nov 16, 2016 8:31 PM UTC

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.

Translate
smacdonald2008
Level 10
Nov 16, 2016 6:52 PM UTC

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

Translate