<a:toolbar id="Toolbar" mapId="Map0" activeTool="ZoomIn"> <a:tool id="ZoomIn" clientAction="EsriMapRectangle" serverAction="com.esri.adf.web.faces.event.ZoomInToolAction" clientPostBack="true"/> <a:tool id="ZoomOut" clientAction="EsriMapRectangle" serverAction="com.esri.adf.web.faces.event.ZoomOutToolAction" clientPostBack="true"/> <a:command id="fullext" clientPostBack="true"> <f:actionListener type="com.esri.adf.web.faces.event.ZoomFullExtentListener"/> </a:command> </a:toolbar>
<a:map id="Map0" value="#{mapContext.webMap}" width="400" height="400" />
在这些代码中,我们看到有个clientAction属性,这是一些javascript脚本的语句,
打开js文件夹中的,esri-map.js中
function EsriMapRectangle(id, toolName, isMarkerTool) { this.inheritsFrom(new EsriMapToolItem(id, toolName, new EsriDrawRectangleAction(), isMarkerTool)); var self = this; this.update = function() { self = this; } this.postAction = function(rect) { if (rect.width == 0 && rect.height == 0) return; self.update(); var map = self.control; if (self.isMarker) map.graphics.drawRectangle(rect); else { if (self.showLoading) map.showLoading(); rect = rect.offset(-map.viewBounds.left, -map.viewBounds.top); EsriUtils.addFormElement(map.formId, map.id, map.id); EsriUtils.addFormElement(map.formId, map.id + "_mode", self.id); EsriUtils.addFormElement(map.formId, map.id + "_minx", rect.left); EsriUtils.addFormElement(map.formId, map.id + "_miny", rect.top); EsriUtils.addFormElement(map.formId, map.id + "_maxx", rect.left + rect.width); EsriUtils.addFormElement(map.formId, map.id + "_maxy", rect.top + rect.height); if (self.clientPostBack) EsriUtils.addFormElement(map.formId, "doPostBack", "doPostBack"); EsriUtils.submitForm(map.formId, self.clientPostBack, EsriControls.processPostBack); } } }
而serverAction指的是服务器端的运行,比如ZoomOutToolAction。
该ZoomOutToolAction继承的是MapToolAction,必须实现execute(MapEvent event) 方法