Skip to main content
Level 2
September 9, 2022
Solved

how to call servlet immediate after dialog close

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.

milind_bachani
milind_bachaniAccepted solution
Adobe Employee
September 9, 2022

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.

7 replies

milind_bachani
Adobe Employee
Adobe Employee
September 9, 2022

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!

Translate
Level 2
September 9, 2022

@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 

Translate
milind_bachani
Adobe Employee
milind_bachaniAdobe EmployeeAccepted solution
Adobe Employee
September 9, 2022

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.

Translate
arunpatidar
Community Advisor
Community Advisor
September 9, 2022

There are different events you can leverage

 

 

Translate
Arun Patidar
Level 2
September 9, 2022

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

Translate
arunpatidar
Community Advisor
Community Advisor
September 11, 2022

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.

Translate
Arun Patidar
nitinn
Adobe Employee
Adobe Employee
September 11, 2022

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

Translate