Snippets/WFSFilter

Untested code from Tim that I didn't want to lose to rafb.net's 24 hour limit: this might help if you care about wfs filters, and is probably a better solution than using a Layer.WFS to solve the problem.

var layer = new OpenLayers.Layer.Vector("My Features");
var format = new OpenLayers.Format.GML({extractAttributes: true});

function callback(request) {
    // maybe you want to destroy all features from your layer first
    layer.destroyFeatures();
    // parse the response
    var features = format.read(request.responseXML || request.responseText);
    // add the new features to your layer
    layer.addFeatures(features);
}

var base = "http://host/path/to/wfs";

// when the user gives you some input, create a filter and other params
var params = {
    "SERVICE": "WFS",
    "VERSION": "1.0.0",
    "REQUEST": "GetFeature",
    "FILTER": "foo"
};

// now issue a request and set your callback 
var url = base + "?" + OpenLayers.Util.getParameterString(params);
var req = OpenLayers.loadURL(url, null, null, callback);
// when the request comes in, your callback will be called

As a complement to the above paste, if you want to serialize a filter, you can do something like the following (also, written in a browser, not tested, etc.):

var filter = new OpenLayers.Filter.Logical({
    type: OpenLayers.Filter.Logical.AND,
    filters: [
        new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.GREATER_THAN,
            property: "AQC_DATE",
            value: "2008-09-01"
        }),
        new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO,
            property: "AQC_DATE",
            value: "2008-09-11"
        })
    ]
});

var format = new OpenLayers.Format.Filter();
var str = format.write(filter);

So, instead of "foo" in the params object above, you could use str from below. And, it all "just (might) work."TM