Alien-Web-ExtJS-V3
view release on metacpan or search on metacpan
share/docs/source/Action2.html view on Meta::CPAN
// shared code among all Actions to validate that there was a response
// with either responseText or responseXml
processResponse : function(response){
this.response = response;
if(!response.responseText && !response.responseXML){
return true;
}
this.result = this.handleResponse(response);
return this.result;
},
decodeResponse: function(response) {
try {
return Ext.decode(response.responseText);
} catch(e) {
return false;
}
},
// utility functions used internally
getUrl : function(appendParams){
var url = this.options.url || this.form.url || this.form.el.dom.action;
if(appendParams){
var p = this.getParams();
if(p){
url = Ext.urlAppend(url, p);
}
}
return url;
},
// private
getMethod : function(){
return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
},
// private
getParams : function(){
var bp = this.form.baseParams;
var p = this.options.params;
if(p){
if(typeof p == "object"){
p = Ext.urlEncode(Ext.applyIf(p, bp));
}else if(typeof p == 'string' && bp){
p += '&' + Ext.urlEncode(bp);
}
}else if(bp){
p = Ext.urlEncode(bp);
}
return p;
},
// private
createCallback : function(opts){
var opts = opts || {};
return {
success: this.success,
failure: this.failure,
scope: this,
timeout: (opts.timeout*1000) || (this.form.timeout*1000),
upload: this.form.fileUpload ? this.success : undefined
};
}
};
<span id='Ext-form-Action-Submit'>/**
</span> * @class Ext.form.Action.Submit
* @extends Ext.form.Action
* <p>A class which handles submission of data from {@link Ext.form.BasicForm Form}s
* and processes the returned response.</p>
* <p>Instances of this class are only created by a {@link Ext.form.BasicForm Form} when
* {@link Ext.form.BasicForm#submit submit}ting.</p>
* <p><u><b>Response Packet Criteria</b></u></p>
* <p>A response packet may contain:
* <div class="mdetail-params"><ul>
* <li><b><code>success</code></b> property : Boolean
* <div class="sub-desc">The <code>success</code> property is required.</div></li>
* <li><b><code>errors</code></b> property : Object
* <div class="sub-desc"><div class="sub-desc">The <code>errors</code> property,
* which is optional, contains error messages for invalid fields.</div></li>
* </ul></div>
* <p><u><b>JSON Packets</b></u></p>
* <p>By default, response packets are assumed to be JSON, so a typical response
* packet may look like this:</p><pre><code>
{
success: false,
errors: {
clientCode: "Client not found",
portOfLoading: "This field must not be null"
}
}</code></pre>
* <p>Other data may be placed into the response for processing by the {@link Ext.form.BasicForm}'s callback
* or event handler methods. The object decoded from this JSON is available in the
* {@link Ext.form.Action#result result} property.</p>
* <p>Alternatively, if an {@link #errorReader} is specified as an {@link Ext.data.XmlReader XmlReader}:</p><pre><code>
errorReader: new Ext.data.XmlReader({
record : 'field',
success: '@success'
}, [
'id', 'msg'
]
)
</code></pre>
* <p>then the results may be sent back in XML format:</p><pre><code>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;message success="false"&gt;
&lt;errors&gt;
&lt;field&gt;
&lt;id&gt;clientCode&lt;/id&gt;
&lt;msg&gt;&lt;![CDATA[Code not found. &lt;br /&gt;&lt;i&gt;This is a test validation message from the server &lt;/i&gt;]]&gt;&lt;/msg&gt;
&lt;/field&gt;
&lt;field&gt;
&lt;id&gt;portOfLoading&lt;/id&gt;
&lt;msg&gt;&lt;![CDATA[Port not found. &lt;br /&gt;&lt;i&gt;This is a test validation message from the server &lt;/i&gt;]]&gt;&lt;/msg&gt;
&lt;/field&gt;
&lt;/errors&gt;
&lt;/message&gt;
</code></pre>
* <p>Other elements may be placed into the response XML for processing by the {@link Ext.form.BasicForm}'s callback
* or event handler methods. The XML document is available in the {@link #errorReader}'s {@link Ext.data.XmlReader#xmlData xmlData} property.</p>
*/
( run in 2.030 seconds using v1.01-cache-2.11-cpan-364913b4093 )