1

I have a two textfields in FormPanel. When one of them is empty, after pressing the search button the form sends the empty string in WFS query. How can I disable the empty field which sends the WFS request after I pressed the search button?

    formPanel = new GeoExt.form.FormPanel({
    ref: "formPanel",
    width: 300,
    height: 200,
    region: "west",
    protocol: protocol,
    buttons:[{
     text: "search",
     handler: function() {
         formPanel.getForm().search();
     },
     //scope: formPanel
 }],
    items: [{
        xtype: "textfield",
        name: "trans_id__eq",
        value: "",
        fieldLabel: "ID",
        disabled: true,
        ref: 'myTextField'
    },

    {
        xtype: "textfield",
        name: "nabywca__eq",
        value: "",
        fieldLabel: "nabywca",
        submitEmptyText: false 
    },
    ],
    listeners: {
        actioncomplete: function(form, action) {
        // this listener triggers when the search request
        // is complete, the OpenLayers.Protocol.Response
        // resulting from the request is available
        // through "action.response"
            features = action.response.features;
            app.featureGrid.store.loadData(features);   //załadowanie zwróconego wyniku wyszukiwania do "app.featureGrid.store"
            vm=app.mapPanel.map.getLayersByName("Results");
            if(vm.length==0){
                vecLayer = new OpenLayers.Layer.Vector("Results");
               app.mapPanel.map.addLayer(vecLayer);
                app.featureGrid.store.bind(vecLayer);
                app.featureGrid.getSelectionModel().bind(vecLayer);
            //app.featureGrid.getSelectionModel().bind(vectorLayer);
        }
    }
    }




})


    );

When I leave blank first textfield and put the value to the second my wfs request send empty string and I get the error.

My protocol:

var protocol= OpenLayers.Protocol.WFS({

            version: "1.1.0",
            url: "http://localhost:8080/geoserver/wfs",
            featureType: "transakcje_punkty",
            featureNS: "http://geoserver.org/transakcje",
             srsName: "EPSG:900913"


        });

Wfs is working properly when I have one field, but I would like to add 7 "textfields".

The user fills the fields with the attributes he want to find and rest leaves empty.

But empty field send some empty value to WFS and I get an error... instead results.

  • 2
    add some code to your question, so people can help you to solve your problem. – Gery Jun 25 '13 at 13:13
  • and where is your protocol? – Gery Jun 25 '13 at 14:56
1

Try replacing

name: "trans_id__eq",

by

name: "transid__eq",

post also your protocol as part of your code, probably there is something wrong there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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