We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37054
    • 93 Posts
    I'm in the process of writing a simple CMP witha a form to do some IO manipulation on the server.

    My formpanel invokes the processor correctly and a success response is sent back but immediately after this response is received I get an Extjs error which prevents my success listener from running.

    Code follows:

    Container component for formpanel:

    Xodus.panel.Home = function(config) {
        config = config || {};
        Ext.apply(config,{
    		formpanel:'xodus.panel.xodus'
            ,url: Xodus.config.connectorUrl
    		,baseParams: { action: 'mgr/xodus/getfile' }
    		,buttons:
        	[{
            	process:'mgr/xodus/getfile'
    			,url: Xodus.config.connectorUrl
    			,text: _('xodus.export')
    			,params: { action: 'mgr/xodus/getfile' }
    			,method: 'remote'
                ,checkDirty: false
                ,keys: [{
                    key: MODx.config.keymap_save || 's'
                    ,alt: true
                    ,ctrl: true
                }]
    		},'-',{
                process: 'cancel'
                ,text: _('xodus.default_back')
                ,params: { a:MODx.action['controllers/index'] }
            }]
    		,components:[{
    				title:_('xodus.export')
    				,xtype: 'xodus-panel-xodus'
                    ,cls: 'main-wrapper'
                    ,preventRender: true
             }]
        });
        Xodus.panel.Home.superclass.constructor.call(this,config);
    };
    Ext.extend(Xodus.panel.Home,MODx.Component);
    Ext.reg('xodus-panel-home',Xodus.panel.Home);
    


    FormPanel Code:
    Xodus.panel.Xodus = function(config) {
        config = config || {};
        Ext.applyIf(config,{
            id: 'xodus.panel.xodus'
            ,url: Xodus.config.connectorUrl
    		,baseParams: { action: 'mgr/xodus/getfile' }
            ,anchor: '98%'
    		,layout:'form'
    		,baseCls:'modx-formpanel'
    		,cls: 'container form-with-labels'
           ,listeners: {
    			'success' : {
                    fn : this.success, 
                    scope : this
                }
            }
    		,items:[{
    			html: '<h2>'+_('xodus.desc')+'</h2><p>' + _('xodus.intro') + '
    
    </p>'
    			,border: false
                ,cls: 'modx-page-header'
            	},
    			{xtype:'modx-combo-usergroup',name:'group',fieldLabel:_('xodus.group'),allowBlank:false,forceSelection:true,blankText:_('xodus.error_group')
          			}
    			,{
    				fieldLabel:_('xodus.format')
    				,header:_('xodus.format')
    				,xtype:'combo'
          			,name:'format'
    				,id:'format'
          			,store: new Ext.data.ArrayStore({
            			id:      0
            			,fields:  [ 'formatID', 'displayText' ]
           				,data: [ [ 0, 'CSV' ], [ 1, 'Excel 2000' ], [ 2, 'Excel 2007' ] ]
          			})
    				,triggerAction: 'all'
         			,typeAhead:false
          			,mode: 'local'
          			,valueField:'formatID'
          			,displayField:'displayText'
          			,allowBlank:false
    				,blankText:_('xodus.error_file_format')
    				,editable:false
          			,forceSelection: true	
    			}]
    	}
    	);
        Xodus.panel.Xodus.superclass.constructor.call(this,config)
    };
    Ext.extend(Xodus.panel.Xodus,MODx.FormPanel,{
    		success:function(o){
    			console.log('success');
    		}
    	});
    Ext.reg('xodus-panel-xodus',Xodus.panel.Xodus);
    


    I have no idea even where to start troubleshooting this apart from disabling the listener which made no difference.

    The error I see is:
    ypeError: g is undefined
    [Break On This Error] 	
    
    ...;if(a.getMonth()==G.getMonth()&&a.getFullYear()==G.getFullYear()){this.cells.rem...
    


    My response from the processor looks like:
    {"success":true,"message":"1352136091.xls","total":0,"errors":[],"object":[]}
    


    Any suggestions? [ed. note: freelancewebdev last edited this post 13 years, 10 months ago.]
      • 37054
      • 93 Posts
      The reason I was getting this error was due to the fact that I wasn't returning an appropriate response from my processor.

      The modx formpanel seems to expect one of two actions to take place at processor level, create or update and in most cases it would be associated with an xpdo object. If you are doing something else, as I was, you are going to have to ensure that the JSON response sent back to the formpanel is in line with what it expects. The minimum response it expects would be:

      {"success":true,"total":0,"message":"","data":[],"object":[]}
      


      Hope this helps someone else doing strange stuff with their processor.