4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-form-action-DirectSubmit'>/**
19 </span> * @class Ext.form.action.DirectSubmit
20 * @extends Ext.form.action.Submit
21 * <p>Provides Ext.direct support for submitting form data.</p>
22 * <p>This example illustrates usage of Ext.direct.Direct to <b>submit</b> a form through Ext.Direct.</p>
23 * <pre><code>
24 var myFormPanel = new Ext.form.Panel({
25 // configs for FormPanel
26 title: 'Basic Information',
27 renderTo: document.body,
28 width: 300, height: 160,
33 myFormPanel.getForm().submit({
42 // configs apply to child items
43 defaults: {anchor: '100%'},
44 defaultType: 'textfield',
52 fieldLabel: 'Company',
56 // configs for BasicForm
58 // The server-side method to call for load() requests
59 load: Profile.getBasicInfo,
60 // The server-side must mark the submit handler as a 'formHandler'
61 submit: Profile.updateBasicInfo
63 // specify the order for the passed params
64 paramOrder: ['uid', 'foo']
66 * </code></pre>
67 * The data packet sent to the server will resemble something like:
68 * <pre><code>
70 "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":"6",
72 "success":true,
74 "extAction":"Profile","extMethod":"updateBasicInfo",
75 "extType":"rpc","extTID":"6","extUpload":"false",
76 "name":"Aaron Conran","email":"aaron@sencha.com","company":"Sencha Inc."
80 * </code></pre>
81 * The form will process a data packet returned by the server that is similar
83 * <pre><code>
84 // sample success packet (batched requests)
87 "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":3,
89 "success":true
94 // sample failure packet (one request)
96 "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":"6",
99 "email":"already taken"
101 "success":false,
102 "foo":"bar"
105 * </code></pre>
106 * Also see the discussion in {@link Ext.form.action.DirectLoad}.
108 Ext.define('Ext.form.action.DirectSubmit', {
109 extend:'Ext.form.action.Submit',
110 requires: ['Ext.direct.Manager'],
111 alternateClassName: 'Ext.form.Action.DirectSubmit',
112 alias: 'formaction.directsubmit',
114 type: 'directsubmit',
116 doSubmit: function() {
118 callback = Ext.Function.bind(me.onSuccess, me),
119 formEl = me.buildForm();
120 me.form.api.submit(formEl, callback, me);
121 Ext.removeNode(formEl);
124 // Direct actions have already been processed and therefore
125 // we can directly set the result; Direct Actions do not have
126 // a this.response property.
127 processResponse: function(result) {
128 return (this.result = result);
131 onSuccess: function(response, trans) {
132 if (trans.type === Ext.direct.Manager.self.exceptions.SERVER) {
135 this.callParent([response]);