I am new to ExtJS and I have the following openlayers code and I am trying to model it into GeoExt Action. The purpose of the code is to create a user drawn Vector Layer polygon, which will fetch the feature attributes of all the WMS feature layer, contained in the user defined polygon.

Here is the code,

    pySelCtrl = new
    OpenLayers.Control.DrawFeature(selectedLayer, OpenLayers.Handler.Polygon, {
                         geodesic: true,
                         handlerOptions: {
                             citeCompliant: false
                     }); // selected layer is an empty vector layer that use
    for drawing selected feature on and for drawing control
                     pySelCtrl.events.register("featureadded", this,
    function (e) {
                         clearData(); // housekeeping (clean up previous
    queries, delete all vectors from selectedLayer)
                         var pfilter = new OpenLayers.Filter.Spatial({
                                 type: OpenLayers.Filter.Spatial.INTERSECTS,
                                 value: e.feature.geometry
    //                    This next piece of code is using application logic
    to find out which fields to fetch back from the server. If you dont
    specify properynames, it will return all of them
                         var propNames = [];
                         var layerNode = getLayerNode(combo.value); // this
    returns application metadata about the layer to query
                         var spatialQueryNode =layerNode.spatialQuery[0]; //
    get the list of fields to return from application metadata
                         for (var i = 0; i < spatialQueryNode.fields.length;
    i++) {
                        if (spatialQueryNode.highlightOnMap)
    propNames.push("SHAPE");     // fetch back geometryif I am going to draw
    the on the map
    // This read queries the server.
                             filter:  pfilter,
                             callback: processSpatialQuery,
                             scope: strategy
I do have the Polygon Draw Action Tool, not sure where to add the eventListener and the rest of the code. Here is my code for the Polygon Draw Tool,

    action = new GeoExt.Action({
            text: "draw poly",
            control: new OpenLayers.Control.DrawFeature(
                features, OpenLayers.Handler.Polygon
            map: map,
            // button options
            toggleGroup: "draw",
            allowDepress: false,
            tooltip: "draw polygon",
            // check item options
            group: "draw"
        actions["draw_poly"] = action;