-
26 Aug 2009 1:54 AM #1
Ext.Direct form submit without formHandler
Ext.Direct form submit without formHandler
Hey Team,
I would like to do an Ext.Direct form Post without "formHandler" set. I.e. I want the form to post JSON.
The get works perfectly. The set however, sends the following:Code:api: { load: MyAPI.get, submit: MyAPI.set }, baseParams: {id: this.customerId}, paramsAsHash: true,
via firebug I see that posted is:Code:that.getForm().submit();
I can just do a form serialise and send the data. But I imagine there is an easier inbuilt way?Code:{"action":"MyAPI","method":"set","data":[{"occupant":{"qtip":""},"other":{"qtip":""}}],"type":"rpc","tid":5}
Scott
-
26 Aug 2009 7:25 PM #2
Why do we ever need to set "formHandler" ? It appears that a form can only post data to Ext.Direct that is setup as a formHandler, and it appears that other request must not be a formHandler or they don't work at all (or at least do not fire when called).
Here is a simple example:
If you set formHandler: true - you do not get a request on the server, nor (obviously) a reply. If you set it to 'false' it all works as expected.Code:Ext.onReady(function(){ Ext.Direct.addProvider({ url: "/direct/cgi/simple/router.cgi", type:"remoting", actions: { Profile: [ { name: 'doTest', len: 1, formHandler: false } ] } }); console.log("Calling doTest"); Profile.doTest('Scott', function(result, e) { console.log("Returned result", result); }); });
Now take the opposite, and use it in a form:
then if you set formHandler: true in the api you get the correct form data posted as expected, but if you set it to false you get:Code:api: { load: Profile.getBasicInfo, submit: Profile.updateBasicInfo },
So there is one of two possibilities I can see.Code:"data":[{"occupant":{"qtip":""},"other":{"qtip":""}}]
- I am not setting it up correctly to allow JSON instead of form data to be sent on a form.
- OR it is unnecessary to setup the formHandler ever because it is implied and internally understood anyway.
Scott
-
10 Sep 2009 12:16 AM #3
We end up doing something like that... (more or less... not sure if it will work because I had to cut/paste part of our class)
The idea is to send this.form.getValues(), not this.form.el.domCode:Ext.form.Action.TefDirectSubmit = Ext.extend(Ext.form.Action.DirectSubmit, { run : function(){ var o = this.options; if(o.clientValidation === false || this.form.isValid()){ // tag on any additional params to be posted in the // form scope this.success.params = this.getParams(); this.form.api.submit(this.form.getValues(), this.success, this); }else if (o.clientValidation !== false){ // client validation failed this.failureType = Ext.form.Action.CLIENT_INVALID; this.form.afterAction(this, false); } } } Ext.form.Action.ACTION_TYPES['directsubmit'] = Ext.form.Action.TefDirectSubmit;


Reply With Quote