1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-form.action.Load'>/**
2 </span> * @class Ext.form.action.Load
3 * @extends Ext.form.action.Action
4 * <p>A class which handles loading of data from a server into the Fields of an {@link Ext.form.Basic}.</p>
5 * <p>Instances of this class are only created by a {@link Ext.form.Basic Form} when
6 * {@link Ext.form.Basic#load load}ing.</p>
7 * <p><u><b>Response Packet Criteria</b></u></p>
8 * <p>A response packet <b>must</b> contain:
9 * <div class="mdetail-params"><ul>
10 * <li><b><code>success</code></b> property : Boolean</li>
11 * <li><b><code>data</code></b> property : Object</li>
12 * <div class="sub-desc">The <code>data</code> property contains the values of Fields to load.
13 * The individual value object for each Field is passed to the Field's
14 * {@link Ext.form.field.Field#setValue setValue} method.</div></li>
15 * </ul></div>
16 * <p><u><b>JSON Packets</b></u></p>
17 * <p>By default, response packets are assumed to be JSON, so for the following form load call:<pre><code>
18 var myFormPanel = new Ext.form.Panel({
19 title: 'Client and routing info',
24 fieldLabel: 'Port of loading',
27 fieldLabel: 'Port of discharge',
28 name: 'portOfDischarge'
31 myFormPanel.{@link Ext.form.Panel#getForm getForm}().{@link Ext.form.Basic#load load}({
32 url: '/getRoutingInfo.php',
34 consignmentRef: myConsignmentRef
36 failure: function(form, action) {
37 Ext.Msg.alert("Load failed", action.result.errorMessage);
40 </code></pre>
41 * a <b>success response</b> packet may look like this:</p><pre><code>
45 clientName: "Fred. Olsen Lines",
46 portOfLoading: "FXT",
47 portOfDischarge: "OSL"
49 }</code></pre>
50 * while a <b>failure response</b> packet may look like this:</p><pre><code>
53 errorMessage: "Consignment reference not found"
54 }</code></pre>
55 * <p>Other data may be placed into the response for processing the {@link Ext.form.Basic Form}'s
56 * callback or event handler methods. The object decoded from this JSON is available in the
57 * {@link Ext.form.action.Action#result result} property.</p>
59 Ext.define('Ext.form.action.Load', {
60 extend:'Ext.form.action.Action',
61 requires: ['Ext.data.Connection'],
62 alternateClassName: 'Ext.form.Action.Load',
63 alias: 'formaction.load',
67 <span id='Ext-form.action.Load-method-run'> /**
71 Ext.Ajax.request(Ext.apply(
72 this.createCallback(),
74 method: this.getMethod(),
76 headers: this.headers,
77 params: this.getParams()
82 <span id='Ext-form.action.Load-method-onSuccess'> /**
85 onSuccess: function(response){
86 var result = this.processResponse(response),
88 if (result === true || !result.success || !result.data) {
89 this.failureType = Ext.form.action.Action.LOAD_FAILURE;
90 form.afterAction(this, false);
94 form.setValues(result.data);
95 form.afterAction(this, true);
98 <span id='Ext-form.action.Load-method-handleResponse'> /**
101 handleResponse: function(response) {
102 var reader = this.form.reader,
105 rs = reader.read(response);
106 data = rs.records && rs.records[0] ? rs.records[0].data : null;
108 success : rs.success,
112 return Ext.decode(response.responseText);
116 </pre></pre></body></html>