Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Page Properties Dialog | EXT Js

CQ_learner
Level 4
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
CQ_learner
Correct answer by
Level 4
Level 4
0 Replies
Amit_Kumar
Community Advisor
Community Advisor

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.

CQ_learner
Level 4
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?

Amit_Kumar
Community Advisor
Community Advisor

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.

Amit_Kumar
Community Advisor
Community Advisor
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.

CQ_learner
Level 4
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
        }
    }

CQ_learner
Correct answer by
Level 4
Level 4