Manipulate string within the author dialog window | Community
Skip to main content
December 16, 2021
Solved

Manipulate string within the author dialog window

  • December 16, 2021
  • 4 replies
  • 1272 views

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.
Best answer by Pavan_Kalyan-1

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.

4 replies

santhosh_kumark
Level 6
December 16, 2021

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.

lukasz-m
Community Advisor
Community Advisor
December 16, 2021

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

manikanthar1295
Level 5
December 16, 2021

@jai_aem ,

 

You can use java script to to achieve this.

 

 

Pavan_Kalyan-1
Pavan_Kalyan-1Accepted solution
Level 3
December 16, 2021

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.

arunpatidar
Community Advisor
Community Advisor
December 18, 2021

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