Expand my Community achievements bar.

SOLVED

How to extend sling postservlet in aem for ok button in dialog.

Avatar

Level 2

After inserting data into dialog it should  save the value in some other location not in /content /pagename/componentname

1 Accepted Solution

Avatar

Correct answer by
Level 8

save : function() {
            var config = {
                url: 'path to servlet',
               ,success: function(){
                    CQ.Ext.Msg.show({
                        title : CQ.I18n.getMessage('Success'),
                        msg : CQ.I18n.getMessage('successfully .'),
                        buttons : CQ.Ext.Msg.OK,
                        icon : CQ.Ext.Msg.INFO
                    });
                },failure: function(){
                    CQ.Ext.Msg.show({
                        title : CQ.I18n.getMessage('Error'),
                        msg : CQ.I18n.getMessage('Save failed, check logs.'),
                        buttons : CQ.Ext.Msg.OK,
                        icon : CQ.Ext.Msg.ERROR
                    });
                }
            };

 

constructor : function(config) {
                       
             config = CQ.Util.applyDefaults(config, {

                resizable : false,
                float : false,
                draggable : false,
                minimizable : false,
                closable : false,
                plain : true,
                layout : "form",
                hidden : false,
                padding : "20px",
                style : {
                    position : "inherit",
                    zIndex : "auto",
                    left : '0px',
                    top : '0px'
                },
                x : 0,
                y : 0,
                defaults : {
                    layout : "form"
                },
                
                disabled: this.readOnly,

               formUrl : url,
                responseScope : this,
                buttons : [ {
                    text : "Save",
                    handler : this.save,
                    scope : this
                } ],
                buttonAlign: "right"
            });

View solution in original post

2 Replies

Avatar

Administrator

Hi 

Same type of question as asked on our older thread :

Link:- https://forums.adobe.com/thread/1170252

//The article covers, How to custom the ok button in the edit dialog

         you have to add cq:editConfig node to your component and define the cq:listners node with what ever the event you want. Please refer below link
        http://dev.day.com/docs/en/cq/current/developing/components/edit_config.html#cq:listeners
 
        Now here you have many events and based on your requirement either you can use client side event (means java script events to track the information for example before/after <action> event from         http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.wcm.EditBar or http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.wcm.EditRollover
 
        OR
 
        you can write your own handler which will help you to do you task, the benefit here is that you will have all the CQ API available to do your job mainly fetching user information from current session.
        http://sling.apache.org/site/eventing-and-jobs.html
 
        but its your choice which best suits to your requirement.
 
        Also if you select client side even handler then ecma script will help you to fetch user information for example take a look at /etc/workflow/scripts/activitystreams/dummy-activity.ecma
 
 

I hope this might help you.

~kautuk



Kautuk Sahni

Avatar

Correct answer by
Level 8

save : function() {
            var config = {
                url: 'path to servlet',
               ,success: function(){
                    CQ.Ext.Msg.show({
                        title : CQ.I18n.getMessage('Success'),
                        msg : CQ.I18n.getMessage('successfully .'),
                        buttons : CQ.Ext.Msg.OK,
                        icon : CQ.Ext.Msg.INFO
                    });
                },failure: function(){
                    CQ.Ext.Msg.show({
                        title : CQ.I18n.getMessage('Error'),
                        msg : CQ.I18n.getMessage('Save failed, check logs.'),
                        buttons : CQ.Ext.Msg.OK,
                        icon : CQ.Ext.Msg.ERROR
                    });
                }
            };

 

constructor : function(config) {
                       
             config = CQ.Util.applyDefaults(config, {

                resizable : false,
                float : false,
                draggable : false,
                minimizable : false,
                closable : false,
                plain : true,
                layout : "form",
                hidden : false,
                padding : "20px",
                style : {
                    position : "inherit",
                    zIndex : "auto",
                    left : '0px',
                    top : '0px'
                },
                x : 0,
                y : 0,
                defaults : {
                    layout : "form"
                },
                
                disabled: this.readOnly,

               formUrl : url,
                responseScope : this,
                buttons : [ {
                    text : "Save",
                    handler : this.save,
                    scope : this
                } ],
                buttonAlign: "right"
            });