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

how to call servlet immediate after dialog close

Avatar

Level 2

how to call servlet via ajax immediate after closing dialog and saving nodes in jcr.

i have requirement to call servlet using dialog data stored in jcr content path immediately dialog is closed.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

A hack would be to add delay in calling the function.

The other option which is more reliable would be to use a resourceListener on node addition/updation.

View solution in original post

7 Replies

Avatar

Employee Advisor

Hi @sudarshanreddy ,

 

You can use following in your component clientlib-JS:

(function(document, $, ns) {
    "use strict";
    $(document).on("click", ".cq-dialog-submit", function(e) {
        $.ajax({
            type: 'GET',
            url: '/your/servlet/path',
            data: {
                text: "TEXT",
                heading: "HEADING"
            },
            success: function(msg) {
                alert('success');
            }
        });
    });
})(document, Granite.$, Granite.author);

Hope this helps, thanks!

Avatar

Level 2

@milind_bachani 

    $(document).on("click", ".cq-dialog-submit", function(e) {

servlet call will be made before node creation in jcr content folder.


looking for servlet call after creating/saving content 

Avatar

Correct answer by
Employee Advisor

A hack would be to add delay in calling the function.

The other option which is more reliable would be to use a resourceListener on node addition/updation.

Avatar

Community Advisor

There are different events you can leverage

 

arunpatidar_0-1662715798182.png

 



Arun Patidar

Avatar

Level 2

just tried everything, its not working... always servlet will be called before saving content into jcr.

Avatar

Community Advisor

you can't call servlet after the saving value but you can write event listener to do same thing that you want to do using servlet.



Arun Patidar

Avatar

Level 1

In your use case, I would suggest you to use Event Listener on node addition.