Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

am new to GeoEXT and am trying to do the search with form panel. and i want to search features from 2 postgis table, published in geoserver, this features correspond to the field on the formpanel and show them on two separated grid panels, when i hit the search button i get nothing on my gridpanel :s here's my java script code:

      // define the data source

        var protocol= OpenLayers.Protocol.WFS({
        url: "http://localhost:8080/geoserver/wfs",
        featureType: "titres_salemed_valid",
        featureNS: "http://geoserver.org/ancfcc"
    });

    var protocol2= OpenLayers.Protocol.WFS({
        url: "http://localhost:8080/geoserver/wfs",
        featureType: "bornes_salemed_valid",
        featureNS: "http://geoserver.org/ancfcc"
    });


   formPanel = new Ext.form.FormPanel({
        title: "Recherche T/R",
        height: 200,
        region: "north",
        items: [{
            xtype: "textfield",
            name: "nature__eq",
            value: "T",
            fieldLabel: "Nature"
        },{
           xtype: "textfield",
           name: "indice__eq",
           value: "20",
           fieldLabel: "Indice"
        },{
           xtype: "textfield",
           name: "num__eq",
           value: "",
           fieldLabel: "Num:"
        },{
           xtype: "textfield",
           name: "complement__eq",
           value: "",
           fieldLabel: "Complement:"
          }],

    // here action on search button 

    buttons: [{text: 'Localiser',
        handler: function(){
   // here to populate the store 2 with feature from table 2 defined by protocol 2

                    formPanel.getForm().doAction(searchAction2, {
                    callback: function(response) {

                                    features2 = searchAction2.response.features;
                                    store2.loadData(features2);

                     };

                     };
// here to populate the store with feature from table  defined by protocol  

                    formPanel.getForm().doAction(searchAction2, {
                    callback: function(response) {

                                    features2 = searchAction2.response.features;
                                    store2.loadData(features2);

};

};

        }
    }]

});

      var searchAction = new GeoExt.form.SearchAction(formPanel.getForm(), {
    protocol: protocol,
    abortPrevious: true
});  

      var searchAction2 = new GeoExt.form.SearchAction(formPanel.getForm(), {
    protocol: protocol2,
    abortPrevious: true
});

      var cols = [ {name: 'titref', type: 'string'},
             {name: 'mappe', type: 'string'},
             {name: 'type', type: 'string'}
           ];

    var reader = new GeoExt.data.FeatureReader({},cols);

    var store = new GeoExt.data.FeatureStore({
        reader: reader,
        fields: cols,
        autoLoad: false
    });


    // pour les titres 

    var cols2 = [ {name: 'name', type: 'string'},
             {name: 'x', type: 'string'},
             {name: 'y', type: 'string'}
           ];

    var reader2 = new GeoExt.data.FeatureReader({},cols2);

    var store2 = new GeoExt.data.FeatureStore({
        reader: reader2,
        fields: cols2,
        autoLoad: false
    });
  // create grid panel configured with feature store
    gridPanel = new Ext.grid.GridPanel({
        title: "results",
        region: "center",
        store: store2,
        height: 100,
        columns: [{
            header: "titref",
            width: 200,
            sortable: true,
            dataIndex: "titref"
        }, {
            header: "mappe",
            width: 60,
            sortable: true,
             dataIndex: "mappe"
        }, {
            header: "type",
            width: 60,
            align: 'right',
            sortable: true,
            dataIndex: "type"
        }],
        sm: select
    });

    // create grid panel configured with feature store for bornes layer
    gridPanel2 = new Ext.grid.GridPanel({
        title: "tableau des bornes",
        region: "south",
        store: store2,
        height: 250,
        columns: [{
            header: "name",
            width: 100,
            sortable: true,
            dataIndex: "name"
        }, {
            header: "x",
            width: 120,
            sortable: true,
            dataIndex: "x"
        }, {
            header: "y",
            width: 120,
            align: 'right',
            sortable: true,
            dataIndex: "y"
        }],
        sm: select2
    });
share|improve this question

2 Answers 2

I'm not sure you can use both protocols at the same time, first use one and see if it works, if so the problem would be that you're trying to gather features from two protocols at the same time. Also you're missing "new" in the protocols, before the OpenLayers.Protocol.WFS. If you're working with a database as backend, eg postgresql/postgis with different tables, simply use UNION and merge everything and put into a new table, in that way you'll use only one protocol, simple like that.

share|improve this answer
    
yes it worked with one protocol. no i don't want to merge the two table, because one records from table 1( wich is table for land parcels) correspond to many records from table 2 (that correspond to boundries of the parcel) Plz if you have any other solution (even if i don't have to use protocol) help meee, thnks –  Geographic May 16 '13 at 12:29

I also have tables like that, I used UNION and one protocol, works perfectly for me. I'm not sure if two protocols can be used because you need to specify one at a time as far as I know. However what you can do is to add a combobox as part of the formpanel and there assign this to each option one cal with the corresponding protocol, it seems a bit hard to do at a first glance but may work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.