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.DirectLoad
17 * @extends Ext.form.action.Load
18 * <p>Provides {@link Ext.direct.Manager} support for loading form data.</p>
19 * <p>This example illustrates usage of Ext.direct.Direct to <b>load</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,
28 // configs apply to child items
29 defaults: {anchor: '100%'},
30 defaultType: 'textfield',
38 fieldLabel: 'Company',
42 // configs for BasicForm
44 // The server-side method to call for load() requests
45 load: Profile.getBasicInfo,
46 // The server-side must mark the submit handler as a 'formHandler'
47 submit: Profile.updateBasicInfo
49 // specify the order for the passed params
50 paramOrder: ['uid', 'foo']
54 myFormPanel.getForm().load({
55 // pass 2 arguments to server side getBasicInfo method (len=2)
62 * The data packet sent to the server will resemble something like:
66 "action":"Profile","method":"getBasicInfo","type":"rpc","tid":2,
67 "data":[34,"bar"] // note the order of the params
71 * The form will process a data packet returned by the server that is similar
72 * to the following format:
76 "action":"Profile","method":"getBasicInfo","type":"rpc","tid":2,
80 "name":"Fred Flintstone",
81 "company":"Slate Rock and Gravel",
82 "email":"fred.flintstone@slaterg.com"
89 Ext.define('Ext.form.action.DirectLoad', {
90 extend:'Ext.form.action.Load',
91 requires: ['Ext.direct.Manager'],
92 alternateClassName: 'Ext.form.Action.DirectLoad',
93 alias: 'formaction.directload',
98 this.form.api.load.apply(window, this.getArgs());
103 * Build the arguments to be sent to the Direct call.
106 getArgs: function() {
110 paramOrder = form.paramOrder,
111 params = me.getParams(),
114 // If a paramOrder was specified, add the params into the argument list in that order.
116 for (i = 0, len = paramOrder.length; i < len; i++) {
117 args.push(params[paramOrder[i]]);
120 // If paramsAsHash was specified, add all the params as a single object argument.
121 else if (form.paramsAsHash) {
125 // Add the callback and scope to the end of the arguments list
126 args.push(me.onSuccess, me);
131 // Direct actions have already been processed and therefore
132 // we can directly set the result; Direct Actions do not have
133 // a this.response property.
134 processResponse: function(result) {
135 return (this.result = result);
138 onSuccess: function(result, trans) {
139 if (trans.type == Ext.direct.Manager.self.exceptions.SERVER) {
142 this.callParent([result]);