Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Dialog Questions

Avatar

Level 2

Hello,

I have a few questions about dialogs. First, here is what I am trying to accomplish. I want to create a component that will be used in 50+ places that will utilize a 'theme' of predefined values. The author would go in and create 2 different 'themes'. The author would then choose which theme to apply to all 50+ instances of this component. half of them would use 'theme 1' and the other half will be using 'theme 2'. Rather than the author having to make these same changes over and over, I want to make it as simple as selecting between 'themes' in a dropdown inside the component. This theme would then have all the values already filled out (possibly residing in a different node) and in the backend, we would use getters to make these values on the 'theme' available to the jsp/html.

So what I had in mind was to create a component that will build these themes out and save them as individual nodes in the JCR to a path provided by a pathfield xtype. Ideally, you can create as many themes as you wish. The only problem I am having is I am not sure how to override the dialog's ok button to POST to a custom URL. I searched and found this post that gives a partial snippet of JavaScript, but I am confused as to how the rest of the file would look. 

Can anyone assist me?

3 Replies

Avatar

Administrator

Hi 

Did you get a chance to look at the post:-

Link:- https://0-forums.adobe.com.libcat.ferris.edu/thread/1170252

//The article covers, How to custom the ok button in the edit dialog

         you have to add cq:editConfig node to your component and define the cq:listners node with what ever the event you want. Please refer below link
        http://dev.day.com/docs/en/cq/current/developing/components/edit_config.html#cq:listeners
 
        Now here you have many events and based on your requirement either you can use client side event (means java script events to track the information for example before/after <action> event from         http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.wcm.EditBar or http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.wcm.EditRollover
 
        OR
 
        you can write your own handler which will help you to do you task, the benefit here is that you will have all the CQ API available to do your job mainly fetching user information from current session.
        http://sling.apache.org/site/eventing-and-jobs.html
 
        but its your choice which best suits to your requirement.
 
        Also if you select client side even handler then ecma script will help you to fetch user information for example take a look at /etc/workflow/scripts/activitystreams/dummy-activity.ecma
 
 

I hope this might help you.

~kautuk



Kautuk Sahni

Avatar

Administrator

Simple Use Case for writing AEM Listeners (Classic UI):

Step 1: Where to place a listener?

This depends on you actually and also the type of listener that you are writing.
For example a dialog listener is kept in the dialog root level as shown below.

Step 2: How to write it?

Step 3:- How to find the event method names?

So here we have used the "beforesubmit" event as shown in the picture above.
To get a list of events for the particular CQ element just go here AEM Widgets API and make a search for your element.

 

For Touch UI:

Link:- https://helpx.adobe.com/experience-manager/using/creating-touchui-events.html

Link:- http://stackoverflow.com/questions/30053519/list-of-listeners-in-aem-6-for-touch-ui

Link:- http://experience-aem.blogspot.in/2015/02/aem-6-sp2-touch-ui-dialog-before-submit.html  // AEM 6 SP2 - Touch UI Dialog Before Submit Confirmation

 

I hope this would be of some help to you.

~kautuk

 

Read full community article :- http://www.codermag.net/2016/03/how-to-write-listener-in-aemcq.html



Kautuk Sahni