3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.form.action.DirectSubmit
17 * @extends Ext.form.action.Submit
18 * <p>Provides Ext.direct support for submitting form data.</p>
19 * <p>This example illustrates usage of Ext.direct.Direct to <b>submit</b> a form through Ext.Direct.</p>
21 var myFormPanel = new Ext.form.Panel({
22 // configs for FormPanel
23 title: 'Basic Information',
24 renderTo: document.body,
25 width: 300, height: 160,
30 myFormPanel.getForm().submit({
39 // configs apply to child items
40 defaults: {anchor: '100%'},
41 defaultType: 'textfield',
49 fieldLabel: 'Company',
53 // configs for BasicForm
55 // The server-side method to call for load() requests
56 load: Profile.getBasicInfo,
57 // The server-side must mark the submit handler as a 'formHandler'
58 submit: Profile.updateBasicInfo
60 // specify the order for the passed params
61 paramOrder: ['uid', 'foo']
64 * The data packet sent to the server will resemble something like:
67 "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":"6",
71 "extAction":"Profile","extMethod":"updateBasicInfo",
72 "extType":"rpc","extTID":"6","extUpload":"false",
73 "name":"Aaron Conran","email":"aaron@sencha.com","company":"Sencha Inc."
78 * The form will process a data packet returned by the server that is similar
81 // sample success packet (batched requests)
84 "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":3,
91 // sample failure packet (one request)
93 "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":"6",
96 "email":"already taken"
103 * Also see the discussion in {@link Ext.form.action.DirectLoad}.
105 Ext.define('Ext.form.action.DirectSubmit', {
106 extend:'Ext.form.action.Submit',
107 requires: ['Ext.direct.Manager'],
108 alternateClassName: 'Ext.form.Action.DirectSubmit',
109 alias: 'formaction.directsubmit',
111 type: 'directsubmit',
113 doSubmit: function() {
115 callback = Ext.Function.bind(me.onSuccess, me),
116 formEl = me.buildForm();
117 me.form.api.submit(formEl, callback, me);
118 Ext.removeNode(formEl);
121 // Direct actions have already been processed and therefore
122 // we can directly set the result; Direct Actions do not have
123 // a this.response property.
124 processResponse: function(result) {
125 return (this.result = result);
128 onSuccess: function(response, trans) {
129 if (trans.type === Ext.direct.Manager.self.exceptions.SERVER) {
132 this.callParent([response]);