Add custom Text Field on creation and store the value of Tag in AEM 6.3 (Touch UI) | Adobe Higher Education
Skip to main content
srinivas_chann1
Level 7
July 18, 2019
Répondu

Add custom Text Field on creation and store the value of Tag in AEM 6.3 (Touch UI)

HI,

For tag edit the below links did work

http://www.flexibledesigns.rs/custom-fields-in-tag-dialogs-for-touch-ui/

https://forums.adobe.com/thread/2390213

But I want a custom textfield when submitted the values must  get stored in crxde. Currently i added   new field under body of

/apps/cq/tagging/gui/content/tags/createtag

The field comes up correctly on web browser  but when clicked on submit the custom  name field value is not getting saved on crx de.

Could some provide inputs as how this could be achieved.

Thanks.

Ce sujet a été fermé aux réponses.
Meilleure réponse par srinivas_chann1

I found the solution to it

Added the new property under create tag

Step1:-

/apps/cq/tagging/gui/content/tags/createtag/jcr:content/body/items/form/items/wizard/items/createStep/items/fixedColumns/items/fixedC olumn1/items

<newtextproperty

                                                            granite:class="block"

                                                            granite:id="tagpimid"

                                                            jcr:primaryType="nt:unstructured"

                                                            sling:resourceType="granite/ui/components/coral/foundation/form/textfield"

                                                            fieldLabel="proerty"

                                                            name="newtagproperty"

                                                            required="{Boolean}true"/>

Step2:-

under /apps/cq/tagging/gui/content/tags/createtag/jcr:content/body/items/form

Change the action to new custom servlet

sling:resourceType="granite/ui/components/coral/foundation/form"

                    action="/bin/tagcommandcreateext"

Step3:-

I found that ootb component on dialog creation sends data  servlet /bin/tagcommand  that is com.day.cq.tagging.servlets.TagCommandServlet

so decode and copy this code to your servlet and remove all the unwanted code expect for createtag code

Step4:- under your new servlet which has servlet path with "/bin/tagcommandcreateext" 

private HtmlResponse createTag(TagManager tagManager, SlingHttpServletRequest request){

    ResourceResolver resourceResolver = null;

   Session session = null;

   

    Map<String, Object> subService = new HashMap<>();

            subService.put(ResourceResolverFactory.SUBSERVICE, SUB_SERVICE);

            resourceResolver = resourceResolverFactory.getServiceResourceResolver(subService);

            session = resourceResolver.adaptTo(Session.class);

 

  try {

                Tag tag = tagManager.createTag(tagID, request.getParameter("jcr:title"),

                        request.getParameter("jcr:description"));

               Node tagNode = session.getNode(tag.getPath());

                tagNode.setProperty("newtagproperty",

                  request.getParameter("newtagproperty"));

     session.save();

                return this.createResponse(200, type + " created", tag.getTagID(), tag.getPath());

            }...

4 commentaires

srinivas_chann1
Level 7
July 19, 2019

Any inputs??

Karl515
Level 5
July 19, 2019

modify the name and granite:id properly

then under tagedit.js

add the ff:

     var myVariable = res["customField-ID"];
     $("#customField-ID").var(myVariable);

btw, I'm 6.4 but I'm assuming it should work just the same.

srinivas_chann1
Level 7
July 19, 2019

Thanks for the input. But i need the same to work when we use create option for tags

I did the same under but does not work

/apps/cq/tagging/gui/content/tags/createtag/jcr:content/body/items/form/items/wizard/items/createStep/items/fixedColumns/items/fixedColumn1/items

Do you have idea what could be reason??

srinivas_chann1
srinivas_chann1AuteurRéponse
Level 7
July 25, 2019

I found the solution to it

Added the new property under create tag

Step1:-

/apps/cq/tagging/gui/content/tags/createtag/jcr:content/body/items/form/items/wizard/items/createStep/items/fixedColumns/items/fixedC olumn1/items

<newtextproperty

                                                            granite:class="block"

                                                            granite:id="tagpimid"

                                                            jcr:primaryType="nt:unstructured"

                                                            sling:resourceType="granite/ui/components/coral/foundation/form/textfield"

                                                            fieldLabel="proerty"

                                                            name="newtagproperty"

                                                            required="{Boolean}true"/>

Step2:-

under /apps/cq/tagging/gui/content/tags/createtag/jcr:content/body/items/form

Change the action to new custom servlet

sling:resourceType="granite/ui/components/coral/foundation/form"

                    action="/bin/tagcommandcreateext"

Step3:-

I found that ootb component on dialog creation sends data  servlet /bin/tagcommand  that is com.day.cq.tagging.servlets.TagCommandServlet

so decode and copy this code to your servlet and remove all the unwanted code expect for createtag code

Step4:- under your new servlet which has servlet path with "/bin/tagcommandcreateext" 

private HtmlResponse createTag(TagManager tagManager, SlingHttpServletRequest request){

    ResourceResolver resourceResolver = null;

   Session session = null;

   

    Map<String, Object> subService = new HashMap<>();

            subService.put(ResourceResolverFactory.SUBSERVICE, SUB_SERVICE);

            resourceResolver = resourceResolverFactory.getServiceResourceResolver(subService);

            session = resourceResolver.adaptTo(Session.class);

 

  try {

                Tag tag = tagManager.createTag(tagID, request.getParameter("jcr:title"),

                        request.getParameter("jcr:description"));

               Node tagNode = session.getNode(tag.getPath());

                tagNode.setProperty("newtagproperty",

                  request.getParameter("newtagproperty"));

     session.save();

                return this.createResponse(200, type + " created", tag.getTagID(), tag.getPath());

            }...