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-DirectLoad'>/**
19 </span> * @class Ext.form.action.DirectLoad
20 * @extends Ext.form.action.Load
21 * <p>Provides {@link Ext.direct.Manager} support for loading form data.</p>
22 * <p>This example illustrates usage of Ext.direct.Direct to <b>load</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,
31 // configs apply to child items
32 defaults: {anchor: '100%'},
33 defaultType: 'textfield',
41 fieldLabel: 'Company',
45 // configs for BasicForm
47 // The server-side method to call for load() requests
48 load: Profile.getBasicInfo,
49 // The server-side must mark the submit handler as a 'formHandler'
50 submit: Profile.updateBasicInfo
52 // specify the order for the passed params
53 paramOrder: ['uid', 'foo']
57 myFormPanel.getForm().load({
58 // pass 2 arguments to server side getBasicInfo method (len=2)
64 * </code></pre>
65 * The data packet sent to the server will resemble something like:
66 * <pre><code>
69 "action":"Profile","method":"getBasicInfo","type":"rpc","tid":2,
70 "data":[34,"bar"] // note the order of the params
73 * </code></pre>
74 * The form will process a data packet returned by the server that is similar
75 * to the following format:
76 * <pre><code>
79 "action":"Profile","method":"getBasicInfo","type":"rpc","tid":2,
81 "success":true,
83 "name":"Fred Flintstone",
84 "company":"Slate Rock and Gravel",
85 "email":"fred.flintstone@slaterg.com"
90 * </code></pre>
92 Ext.define('Ext.form.action.DirectLoad', {
93 extend:'Ext.form.action.Load',
94 requires: ['Ext.direct.Manager'],
95 alternateClassName: 'Ext.form.Action.DirectLoad',
96 alias: 'formaction.directload',
101 this.form.api.load.apply(window, this.getArgs());
104 <span id='Ext-form-action-DirectLoad-method-getArgs'> /**
106 * Build the arguments to be sent to the Direct call.
109 getArgs: function() {
113 paramOrder = form.paramOrder,
114 params = me.getParams(),
117 // If a paramOrder was specified, add the params into the argument list in that order.
119 for (i = 0, len = paramOrder.length; i < len; i++) {
120 args.push(params[paramOrder[i]]);
123 // If paramsAsHash was specified, add all the params as a single object argument.
124 else if (form.paramsAsHash) {
128 // Add the callback and scope to the end of the arguments list
129 args.push(me.onSuccess, me);
134 // Direct actions have already been processed and therefore
135 // we can directly set the result; Direct Actions do not have
136 // a this.response property.
137 processResponse: function(result) {
138 return (this.result = result);
141 onSuccess: function(result, trans) {
142 if (trans.type == Ext.direct.Manager.self.exceptions.SERVER) {
145 this.callParent([result]);