Manipulate string within the author dialog window | Community
Skip to main content
New Participant
Dec 16, 2021 6:12 AM UTC
Solved

Manipulate string within the author dialog window

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Pavan_Kalyan-1
Pavan_Kalyan-1Accepted solution
Level 3
Dec 16, 2021 9:16 AM UTC

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.

5 replies

arunpatidar
New Participant
Dec 18, 2021 3:50 PM UTC

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/

 

Translate
Arun Patidar
manikanthar1295
Level 5
Dec 16, 2021 8:44 AM UTC

@jai_aem ,

 

You can use java script to to achieve this.

 

 

Translate
Pavan_Kalyan-1
Pavan_Kalyan-1Accepted solution
Level 3
Dec 16, 2021 9:16 AM UTC

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.

Translate
lukasz-m
New Participant
Dec 16, 2021 7:50 AM UTC

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

Translate
santhosh_kumark
Level 6
Dec 16, 2021 7:28 AM UTC

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.

Translate