Hybrid View

Modeling OpenLayers code to GeoExt Action

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,

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++) {
propNames.push(spatialQueryNode.fields[i].id);
}
//
if (spatialQueryNode.highlightOnMap)
propNames.push("SHAPE"); // fetch back geometryif I am going to draw
the on the map
// This read queries the server.
wfsProtocol[combo.value].read({
filter: pfilter,
propertyNames:propNames,
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,

I have the code but I am confused as to how I should place it in the GeoExt.Action so that I can call it when the tool draws the desired polygon. I am using the ExtJS for the first time, so needed some assistance.

The console.log(action) returns a object. It is really big one. Even u can see it now in the the link I sent. The short version of the object looks like this,
Object { control={...}, activateOnEnable=false, deactivateOnDisable=false, more...}