Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/GeoExt/lib/GeoExt/data/ProtocolProxy.js @ 76

Revision 76, 4.2 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/**
2 * Copyright (c) 2008-2010 The Open Source Geospatial Foundation
3 *
4 * Published under the BSD license.
5 * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
6 * of the license.
7 */
8
9/** api: (define)
10 *  module = GeoExt.data
11 *  class = ProtocolProxy
12 *  base_link = `Ext.data.DataProxy <http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.DataProxy>`_
13 */
14Ext.namespace('GeoExt', 'GeoExt.data');
15
16GeoExt.data.ProtocolProxy = function(config) {
17    Ext.apply(this, config);
18    GeoExt.data.ProtocolProxy.superclass.constructor.apply(this, arguments);
19};
20
21/** api: constructor
22 *  .. class:: ProtocolProxy
23 *   
24 *      A data proxy for use with ``OpenLayers.Protocol`` objects.
25 */
26Ext.extend(GeoExt.data.ProtocolProxy, Ext.data.DataProxy, {
27
28    /** api: config[protocol]
29     *  ``OpenLayers.Protocol``
30     *  The protocol used to fetch features.
31     */
32    protocol: null,
33
34    /** api: config[abortPrevious]
35     *  ``Boolean``
36     *  Abort any previous request before issuing another.  Default is ``true``.
37     */
38    abortPrevious: true,
39
40    /** api: config[setParamsAsOptions]
41     *  ``Boolean``
42     *  Should options.params be set directly on options before passing it into
43     *  the protocol's read method? Default is ``false``.
44     */
45    setParamsAsOptions: false,
46
47    /** private: property[response]
48     *  ``OpenLayers.Protocol.Response``
49     *  The response returned by the read call on the protocol.
50     */
51    response: null,
52
53    /** private: method[load]
54     *  :param params: ``Object`` An object containing properties which are to
55     *      be used as HTTP parameters for the request to the remote server.
56     *  :param reader: ``Ext.data.DataReader`` The Reader object which converts
57     *      the data object into a block of ``Ext.data.Records``.
58     *  :param callback: ``Function`` The function into which to pass the block
59     *      of ``Ext.data.Records``. The function is passed the Record block
60     *      object, the ``args`` argument passed to the load function, and a
61     *      boolean success indicator.
62     *  :param scope: ``Object`` The scope in which to call the callback.
63     *  :param arg: ``Object`` An optional argument which is passed to the
64     *      callback as its second parameter.
65     *
66     *  Calls ``read`` on the protocol.
67     */
68    load: function(params, reader, callback, scope, arg) {
69        if (this.fireEvent("beforeload", this, params) !== false) {
70            var o = {
71                params: params || {},
72                request: {
73                    callback: callback,
74                    scope: scope,
75                    arg: arg
76                },
77                reader: reader
78            };
79            var cb = OpenLayers.Function.bind(this.loadResponse, this, o);
80            if (this.abortPrevious) {
81                this.abortRequest();
82            }
83            var options = {
84                params: params,
85                callback: cb,
86                scope: this
87            };
88            Ext.applyIf(options, arg);
89            if (this.setParamsAsOptions === true) {
90                Ext.applyIf(options, options.params);
91                delete options.params;
92            }
93            this.response = this.protocol.read(options);
94        } else {
95           callback.call(scope || this, null, arg, false);
96        }
97    },
98
99    /** private: method[abortRequest]
100     *  Called to abort any ongoing request.
101     */
102    abortRequest: function() {
103        if (this.response) {
104            this.protocol.abort(this.response);
105            this.response = null;
106        }
107    },
108
109    /** private: method[loadResponse]
110     *  :param o: ``Object``
111     *  :param response: ``OpenLayers.Protocol.Response``
112     * 
113     *  Handle response from the protocol
114     */
115    loadResponse: function(o, response) {
116        if (response.success()) {
117            var result = o.reader.read(response);
118            this.fireEvent("load", this, o, o.request.arg);
119            o.request.callback.call(
120               o.request.scope, result, o.request.arg, true);
121        } else {
122            this.fireEvent("loadexception", this, o, response);
123            o.request.callback.call(
124                o.request.scope, null, o.request.arg, false);
125        }
126    }
127});
Note: See TracBrowser for help on using the repository browser.