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

Page Properties Dialog | EXT Js

Avatar

Level 4

Hi - I am working on a custom function in EXTjs..where in i am doing some field validation before submit of Page Properties Dialog. and based on a business logic I will be displaying CQ.Ext.Msg.show message to the author (Yes or No), the issue is now when the author selects Yes or No ,Also I am making a servlet call when author clicks on Yes or No,Now the question is how do I close the page properties dialog by saving all the changes made by the author if any and reload the page? Can someone please tell me how i can handle this..

 

Thanks in Advance!!

1 Accepted Solution

Avatar

Correct answer by
Level 4
6 Replies

Avatar

Level 10

You have to use closeAction or close() from dialog after your servlet success.

Read https://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.Dialog for more details.

Avatar

Level 4

Amit_Kumar wrote...

You have to use closeAction or close() from dialog after your servlet success.

Read https://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.Dialog for more details.

 

Hi Amit - thanks for your reply i used CQ.Dialog.close(); but it says its not a function. Can you tell me how i can use it?

Avatar

Level 10

if you are using EXTJS then use CQ.Dialog.close(CQ.Dialog.closeAction);
if inside the dialog use this.close(closeAction);
if you are using a tabpanel or window use window.close();

or you can share the the code here so that i can see what you want to achieve with this.

Avatar

Level 10
Ext.application({ name:'MyApp' ,requires:[ 'Ext.window.MessageBox' ]  ,launch:function() { Ext.create('Ext.window.Window', { title:'Test' ,width:400 ,height:300 ,autoShow:true ,listeners:{ beforeclose:function(win) { // user has already answered yes if(win.closeMe) { win.closeMe = false; return true; } // ask user if really close Ext.Msg.show({ title:'Close confirmation' ,msg:'Really close?' ,buttons:Ext.Msg.YESNO ,callback:function(btn) { if('yes' === btn) { // save the user answer win.closeMe = true; // call close once again win.close(); } } }); // Always cancel closing if we get here return false; } } }); } });

This a sample for EXT JS code.. Hope you can use this to suit your requirements. dialog extend window object so all window methods will be available for dialog.

Avatar

Level 4

Hi Thanks for the code, but here I already have a dialog so i do not have to create a dialog, which i need to save and close. when the user clicks on yes or no.

Below is the code i have..This is called when page Properties dialog opens up

pageProperties.functionName = 
function(obj){
var url = '/bin/admin/servlet?params';
        var result =CQ.shared.HTTP.get(url);
        if(result != null && result.responseText != ""){
            CQ.Ext.Msg.show({
                title:'ALERT!!!',
                msg: 'Click Yes to override details Else Click No',
                buttons: CQ.Ext.Msg.YESNO,
                icon: CQ.Ext.MessageBox.WARNING,
                animEl: 'elId',
                fn: function(btn){ 
                    if(btn == 'yes'){
                        $.ajax({
                            type: 'POST',
                            url: '/bin/admin/servlet',
                            data: 'data='+data+'&override=' + btn
                        });
                        //insert code to save and close dialog
                    } else {
                        $.ajax({
                            type: 'POST',
                            url: '/bin/admin/servlet',
                            data: 'data='+data+'&override=' + btn
                        });
                        //insert code to save and close dialog
                    }
                }
            });
            return false; // to stop page load
        }
    }

Avatar

Correct answer by
Level 4

Got the solution for this i used SlingSubmitAction...here is the link https://docs.adobe.com/docs/en/cq/5-6-1/widgets-api/index.html?class=CQ.form.SlingSubmitAction