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/widgets/form/SearchAction.js @ 81

Revision 76, 5.1 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.form
11 *  class = SearchAction
12 *  base_link = `Ext.form.Action <http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.Action>`_
13 */
14
15/**
16 * @include GeoExt/widgets/form.js
17 */
18
19Ext.namespace("GeoExt.form");
20 
21/** api: example
22 *  Sample code showing how to use a GeoExt SearchAction with an Ext form panel:
23 * 
24 *  .. code-block:: javascript
25 *
26 *      var formPanel = new Ext.form.Panel({
27 *          renderTo: "formpanel",
28 *          items: [{
29 *              xtype: "textfield",
30 *              name: "name__like",
31 *              value: "mont"
32 *          }, {
33 *              xtype: "textfield",
34 *              name: "elevation__ge",
35 *              value: "2000"
36 *          }]
37 *      });
38 *
39 *      var searchAction = new GeoExt.form.SearchAction(formPanel.getForm(), {
40 *          protocol: new OpenLayers.Protocol.WFS({
41 *              url: "http://publicus.opengeo.org/geoserver/wfs",
42 *              featureType: "tasmania_roads",
43 *              featureNS: "http://www.openplans.org/topp"
44 *          }),
45 *          abortPrevious: true
46 *      });
47 *
48 *      formPanel.getForm().doAction(searchAction, {
49 *          callback: function(response) {
50 *              // response.features includes the features read
51 *              // from the server through the protocol
52 *          }
53 *      });
54 */
55
56/** api: constructor
57 *  .. class:: SearchAction(form, options)
58 *
59 *      A specific ``Ext.form.Action`` to be used when using a form to do
60 *      trigger search requests througn an ``OpenLayers.Protocol``.
61 *
62 *      Arguments:
63 *
64 *      * form ``Ext.form.BasicForm`` A basic form instance.
65 *      * options ``Object`` Options passed to the protocol'read method
66 *            One can add an abortPrevious property to these options, if set
67 *            to true, the abort method will be called on the protocol if
68 *            there's a pending request.
69 *
70 *      When run this action builds an ``OpenLayers.Filter`` from the form
71 *      and passes this filter to its protocol's read method. The form fields
72 *      must be named after a specific convention, so that an appropriate
73 *      ``OpenLayers.Filter.Comparison`` filter is created for each
74 *      field.
75 *
76 *      For example a field with the name ``foo__like`` would result in an
77 *      ``OpenLayers.Filter.Comparison`` of type
78 *      ``OpenLayers.Filter.Comparison.LIKE`` being created.
79 *
80 *      Here is the convention:
81 *
82 *      * ``<name>__eq: OpenLayers.Filter.Comparison.EQUAL_TO``
83 *      * ``<name>__ne: OpenLayers.Filter.Comparison.NOT_EQUAL_TO``
84 *      * ``<name>__lt: OpenLayers.Filter.Comparison.LESS_THAN``
85 *      * ``<name>__le: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO``
86 *      * ``<name>__gt: OpenLayers.Filter.Comparison.GREATER_THAN``
87 *      * ``<name>__ge: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO``
88 *      * ``<name>__like: OpenLayers.Filter.Comparison.LIKE``
89 *
90 *      In most cases your would not directly create ``GeoExt.form.SearchAction``
91 *      objects, but use :class:`GeoExt.form.FormPanel` instead.
92 */
93GeoExt.form.SearchAction = Ext.extend(Ext.form.Action, {
94    /** private: property[type]
95     *  ``String`` The action type string.
96     */
97    type: "search",
98
99    /** api: property[response]
100     *  ``OpenLayers.Protocol.Response`` A reference to the response
101     *  resulting from the search request. Read-only.
102     */
103    response: null,
104
105    /** private */
106    constructor: function(form, options) {
107        GeoExt.form.SearchAction.superclass.constructor.call(this, form, options);
108    },
109
110    /** private: method[run]
111     *  Run the action.
112     */
113    run: function() {
114        var o = this.options;
115        var f = GeoExt.form.toFilter(this.form, o.logicalOp, o.wildcard);
116        if(o.clientValidation === false || this.form.isValid()){
117
118            if (o.abortPrevious && this.form.prevResponse) {
119                o.protocol.abort(this.form.prevResponse);
120            }
121
122            this.form.prevResponse = o.protocol.read(
123                Ext.applyIf({
124                    filter: f,
125                    callback: this.handleResponse,
126                    scope: this
127                }, o)
128            );
129
130        } else if(o.clientValidation !== false){
131            // client validation failed
132            this.failureType = Ext.form.Action.CLIENT_INVALID;
133            this.form.afterAction(this, false);
134        }
135    },
136
137    /** private: method[handleResponse]
138     *  :param response: ``OpenLayers.Protocol.Response`` The response
139     *  object.
140     *
141     *  Handle the response to the search query.
142     */
143    handleResponse: function(response) {
144        this.form.prevResponse = null;
145        this.response = response;
146        if(response.success()) {
147            this.form.afterAction(this, true);
148        } else {
149            this.form.afterAction(this, false);
150        }
151        var o = this.options;
152        if(o.callback) {
153            o.callback.call(o.scope, response);
154        }
155    }
156});
Note: See TracBrowser for help on using the repository browser.