Grails/Groovy Controller should return Success to ExtJS -


i trying simple extjs - grails/groovy test. groovy server page ( gsp ) file contains below extjs code:

  • it has 2 fields state code , state name.
  • user enters details , click on submit.
  • the submit triggers handler further posts form controller class.

function createtender() {       var submithandler = function() {       alert("submit pressed !");       var formpanel = ext.getcmp('stateform');       formpanel.getform().submit({         url     : 'state/savestate',         method  : 'post',         success : function() {         alert('state saved successfully!');       },       failure : function() {         alert('state save failed!');       }     });  }   ext.create('ext.form.panel',{     id: 'stateform',     height: 300,     width: 400,     bodypadding: 10,     title: 'create state',     items: [{       xtype:'textfield',       fieldlabel: 'state code',       name: 'statecode',       allowblank:false     }, {       xtype:'textfield',       fieldlabel: 'state name',       name: 'statename'     }],           buttons: [{       text: 'save',       handler: submithandler     },{       text: 'cancel'     }],     renderto: ext.getbody()     });   } 

below statecontroller class action/method savestate. prints state code , nothing.

class statecontroller {   static scaffold = true   def savestate = {     println "into savetender() method !!!"     println params.statecode     // steps save state code , name database.   } } 

problem:

  • the savestate method printing both println statements. however, can see, not returning anything, because don't know should return gsp. intention save state details , throw alert saying 'state saved successfully!' message.
  • but, ext code in gsp throwing "state save failed!" message.

i want return success controller gsp. how do it? please don't mind if question naive beginner.

        render(contenttype: "text/json") {                array = {                    result "success": 'true',                           "message": 'state saved'                }         } 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -