How to set default value for tag picker | Community
Skip to main content
New Participant
November 8, 2017
Solved

How to set default value for tag picker

  • November 8, 2017
  • 8 replies
  • 6062 views

I want to set a default value for my cq:tag which is using a tagpicker (cq/gui/components/common/tagspicker). Is there anyone know how to configure it? I am using AEM 6.3 touch UI.

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 jerryru

I made it by adding listeners.js in clientlins folder to the component. The following is example:

$document.on("dialog-ready", function() {

       // add logic here

    });

8 replies

jerryruAuthorAccepted solution
New Participant
November 29, 2017

I made it by adding listeners.js in clientlins folder to the component. The following is example:

$document.on("dialog-ready", function() {

       // add logic here

    });

New Participant
November 15, 2017

A small tweak to the Listener, just to avoid showing the defaultValue even after modifying the Tag Field values.

'tagname' is name of the tag.

function(field, record)

{

     if(record.get('tagname') == undefined)

     {

          var x=[field.defaultValue];

          field.setValue(x);

     }

}

smacdonald2008
New Participant
November 8, 2017

Keep in mind xtype is for Classic UI.

Hemant_arora
New Participant
November 8, 2017

Set the default value  and

Add a listeners node to your xtype tags and add the loadcontent function to your listener

Working example : function(field){var x=[field.defaultValue];field.setValue(x);}

Further u can tweak the loadcontent function to retrieve the new selected values

jerryruAuthor
New Participant
November 8, 2017

Thanks for your response and sharing. Really appreciate!!

jerryruAuthor
New Participant
November 8, 2017

Thanks for your response. I want to set a default value on my "cq:tags" field of my component via dialog configurations. Is it possible? I am trying to set a "value" or "defaultValue". Unfortunately, both of them don't work.

kautuk_sahni
Employee
November 8, 2017

I would recommend you to have a look at this documentation: Overview of the Tagging API

The implementation of the tagging framework  in AEM allows management of tags and tag content using the JCR API . The TagManager ensures that tags entered as values on the cq:tags string array property are not duplicated, it removes TagIDs pointing to non-existing tags and updates TagIDs for moved or merged tags. TagManager uses a JCR observation listener that reverts any incorrect changes. The main classes are in the com.day.cq.tagging package:

  • JcrTagManagerFactory - returns a JCR-based implementation of a TagManager. It is the reference implementation of the Tagging API.
  • TagManager -  allows for resolving and creating tags by paths and names.
  • Tag - defines the tag object
Kautuk Sahni
smacdonald2008
New Participant
November 8, 2017

I am not aware of how to set a default - when you click on this field - it opens the JCR dialog where an author selects tags,

A community article that uses tag picker -- Adobe Experience Manager Help | Developing HTML Template Language Components that search for Adobe Experience Manager Co…