2 * @class Ext.form.action.DirectSubmit
3 * @extends Ext.form.action.Submit
4 * <p>Provides Ext.direct support for submitting form data.</p>
5 * <p>This example illustrates usage of Ext.direct.Direct to <b>submit</b> a form through Ext.Direct.</p>
7 var myFormPanel = new Ext.form.Panel({
8 // configs for FormPanel
9 title: 'Basic Information',
10 renderTo: document.body,
11 width: 300, height: 160,
16 myFormPanel.getForm().submit({
25 // configs apply to child items
26 defaults: {anchor: '100%'},
27 defaultType: 'textfield',
35 fieldLabel: 'Company',
39 // configs for BasicForm
41 // The server-side method to call for load() requests
42 load: Profile.getBasicInfo,
43 // The server-side must mark the submit handler as a 'formHandler'
44 submit: Profile.updateBasicInfo
46 // specify the order for the passed params
47 paramOrder: ['uid', 'foo']
50 * The data packet sent to the server will resemble something like:
53 "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":"6",
57 "extAction":"Profile","extMethod":"updateBasicInfo",
58 "extType":"rpc","extTID":"6","extUpload":"false",
59 "name":"Aaron Conran","email":"aaron@sencha.com","company":"Sencha Inc."
64 * The form will process a data packet returned by the server that is similar
67 // sample success packet (batched requests)
70 "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":3,
77 // sample failure packet (one request)
79 "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":"6",
82 "email":"already taken"
89 * Also see the discussion in {@link Ext.form.action.DirectLoad}.
91 Ext.define('Ext.form.action.DirectSubmit', {
92 extend:'Ext.form.action.Submit',
93 requires: ['Ext.direct.Manager'],
94 alternateClassName: 'Ext.form.Action.DirectSubmit',
95 alias: 'formaction.directsubmit',
99 doSubmit: function() {
101 callback = Ext.Function.bind(me.onSuccess, me),
102 formEl = me.buildForm();
103 me.form.api.submit(formEl, callback, me);
104 Ext.removeNode(formEl);
107 // Direct actions have already been processed and therefore
108 // we can directly set the result; Direct Actions do not have
109 // a this.response property.
110 processResponse: function(result) {
111 return (this.result = result);
114 onSuccess: function(response, trans) {
115 if (trans.type === Ext.direct.Manager.self.exceptions.SERVER) {
118 this.callParent([response]);