Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Manipulate string within the author dialog window

JAI_AEM
Level 1
Level 1

Hi, 

I'm learning AEM. I would like to know, is there a way to manipulate(perform string operation) the text that we get from the author dialog window and display the manipulated string in the same field. So that the author could see the manipulated text the next time he opens the dialog(without any additional event listeners).

For example, if the author inputs google in the text field and closes the author dialog window - when the dialog window is opened for the next time, the text should be something like google.com instead of just google.

1 Accepted Solution
kalyan_maverick
Correct answer by
Level 3
Level 3

Hi @JAI_AEM 

you can add the .com using sling model in the getter method but it is only displayed in the component property. but you can't see the google+.com in your dialog. I remains the same (google) in your dialog.

thanks.

View solution in original post

5 Replies
santhosh_kumark
Community Advisor
Community Advisor

Hi @JAI_AEM ,

 

You can achieve this in the component sling model class. Inject the required property in sling model and update its value using setProperty in its init() method.

lukaszm
Level 7
Level 7

Hi @JAI_AEM, if you want to change value of property set via dialog by author, than in my opinion SlingPostProcessor [1] will be the right thing to use.

[1] - https://sling.apache.org/apidocs/sling5/org/apache/sling/servlets/post/SlingPostProcessor.html

kalyan_maverick
Correct answer by
Level 3
Level 3

Hi @JAI_AEM 

you can add the .com using sling model in the getter method but it is only displayed in the component property. but you can't see the google+.com in your dialog. I remains the same (google) in your dialog.

thanks.

View solution in original post

Arun_Patidar
Community Advisor
Community Advisor

Hi,

You can use javascript to change the authored content on dialog save event.

1. create a clientlibs with category of cq.authoring.dialog

2. write a listner on save

3. read/change the content and set the value

 

$(document).on("click", ".cq-dialog-submit", function (e) {
            //$(window).adaptTo("foundation-ui").alert("Close", "Dialog closed, selector [.cq-dialog-submit]");
        });

 

check below article for example 

https://aemsimplifiedbynikhil.wordpress.com/2018/07/30/touchui-dialog-listeners-aem-6-3/