X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..10a866c12701c0a0afd0ac85dcdcf32a421514ac:/src/data/XmlWriter.js?ds=inline
diff --git a/src/data/XmlWriter.js b/src/data/XmlWriter.js
index a4aabbca..45821108 100644
--- a/src/data/XmlWriter.js
+++ b/src/data/XmlWriter.js
@@ -1,5 +1,5 @@
/*!
- * Ext JS Library 3.0.0
+ * Ext JS Library 3.1.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
@@ -8,38 +8,151 @@
* @class Ext.data.XmlWriter
* @extends Ext.data.DataWriter
* DataWriter extension for writing an array or single {@link Ext.data.Record} object(s) in preparation for executing a remote CRUD action via XML.
+ * XmlWriter uses an instance of {@link Ext.XTemplate} for maximum flexibility in defining your own custom XML schema if the default schema is not appropriate for your needs.
+ * See the {@link #tpl} configuration-property.
*/
-Ext.data.XmlWriter = Ext.extend(Ext.data.DataWriter, {
+Ext.data.XmlWriter = function(params) {
+ Ext.data.XmlWriter.superclass.constructor.apply(this, arguments);
+ // compile the XTemplate for rendering XML documents.
+ this.tpl = (typeof(this.tpl) === 'string') ? new Ext.XTemplate(this.tpl).compile() : this.tpl.compile();
+};
+Ext.extend(Ext.data.XmlWriter, Ext.data.DataWriter, {
/**
- * Final action of a write event. Apply the written data-object to params.
- * @param {String} action [Ext.data.Api.create|read|update|destroy]
- * @param {Record[]} rs
- * @param {Object} http params
- * @param {Object} data object populated according to DataReader meta-data "root" and "idProperty"
+ * @cfg {String} documentRoot [xrequest] (Optional) The name of the XML document root-node. Note:
+ * this parameter is required only when sending extra {@link Ext.data.Store#baseParams baseParams} to the server
+ * during a write-request -- if no baseParams are set, the {@link Ext.data.XmlReader#record} meta-property can
+ * suffice as the XML document root-node for write-actions involving just a single record. For requests
+ * involving multiple records and NO baseParams, the {@link Ext.data.XmlWriter#root} property can
+ * act as the XML document root.
*/
- render : function(action, rs, params, data) {
- // no impl.
+ documentRoot: 'xrequest',
+ /**
+ * @cfg {Boolean} forceDocumentRoot [false] Set to true to force XML documents having a root-node as defined
+ * by {@link #documentRoot}, even with no baseParams defined.
+ */
+ forceDocumentRoot: false,
+ /**
+ * @cfg {String} root [records] The name of the containing element which will contain the nodes of an write-action involving multiple records. Each
+ * xml-record written to the server will be wrapped in an element named after {@link Ext.data.XmlReader#record} property.
+ * eg:
+
+ * However, when multiple records are written in a batch-operation, these records must be wrapped in a containing
+ * Element.
+ * eg:
+
+<?xml version="1.0" encoding="UTF-8"?>
+<user><first>Barney</first></user>
+
+ * Defaults to records. Do not confuse the nature of this property with that of {@link #documentRoot}
+ */
+ root: 'records',
+ /**
+ * @cfg {String} xmlVersion [1.0] The version written to header of xml documents.
+
+<?xml version="1.0" encoding="UTF-8"?>
+ <records>
+ <first>Barney</first></user>
+ <records><first>Barney</first></user>
+ </records>
+
+ */
+ xmlVersion : '1.0',
+ /**
+ * @cfg {String} xmlEncoding [ISO-8859-15] The encoding written to header of xml documents.
+<?xml version="1.0" encoding="ISO-8859-15"?>
+ */
+ xmlEncoding: 'ISO-8859-15',
+ /**
+ * @cfg {String/Ext.XTemplate} tpl The XML template used to render {@link Ext.data.Api#actions write-actions} to your server.
+ * <?xml version="1.0" encoding="ISO-8859-15"?>
One can easily provide his/her own custom {@link Ext.XTemplate#constructor template-definition} if the default does not suffice.
+ *Defaults to:
+
+<?xml version="{version}" encoding="{encoding}"?>
+ <tpl if="documentRoot"><{documentRoot}>
+ <tpl for="baseParams">
+ <tpl for=".">
+ <{name}>{value}</{name}>
+ </tpl>
+ </tpl>
+ <tpl if="records.length > 1"><{root}>',
+ <tpl for="records">
+ <{parent.record}>
+ <tpl for=".">
+ <{name}>{value}</{name}>
+ </tpl>
+ </{parent.record}>
+ </tpl>
+ <tpl if="records.length > 1"></{root}></tpl>
+ <tpl if="documentRoot"></{documentRoot}></tpl>
+
+ * Templates will be called with the following API
+ *