Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Manipulate string within the author dialog window

Avatar

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

Avatar

Correct answer by
Level 4

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

Avatar

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.

Avatar

Community Advisor

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

Avatar

Level 6

@JAI_AEM ,

 

You can use java script to to achieve this.

 

 

Avatar

Correct answer by
Level 4

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.

Avatar

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/

 



Arun Patidar