Analysis of the interaction process between ArcGis Server ADF Toolbar and Map client and Server 2

Source: Internet
Author: User

2. How does the client send information to the server?

When we click a button on the toolbar, ToolbarMouseDown () is executed according to the above analysis.

Let's take a look at what ToolbarMouseDown () does:

Function ToolbarMouseDown (toolbarName, toolbarItemName, buttonType, e)
{
.......
If (buttonType = "Tool "){
......
Var clientAction = toolbar. items [toolbarItemName]. clientAction;
If (clientAction! = Null)
{
Var clientActions = "";
If (! Toolbar. items [toolbarItemName]. isClientActionCustom)
{
Var buddies = toolbar. buddyControls;
If (buddies! = Null ){
For (var I = 0; I <buddies. length; I ++)
{
Var modeField = f. elements [buddies [I] + "_ mode"];
If (modeField! = Null)
ModeField. value = toolbarItemName;
Var cursor = toolbar. items [toolbarItemName]. cursor;
If (cursor! = Null)
ClientActions = clientActions + clientAction + "('" + buddies [I] + "', '" + toolbarItemName + "'," + toolbar. items [toolbarItemName]. showLoading + ", '" + cursor + "');";
Else
ClientActions = clientActions + clientAction + "('" + buddies [I] + "', '" + toolbarItemName + "'," + toolbar. items [toolbarItemName]. showLoading + ");";
}
}
}
Else
{
ClientActions = clientAction;
}

...
If (toolbar. items [toolbarItemName]. preExecFunction! = Null)
ClientActions + = toolbar. items [toolbarItemName]. preExecFunction;

// Call ClientAction
Var clientActionFunction = new Function (clientActions );
ClientActionFunction. call (null );

// Select this tool and unselect others
Toolbars [toolbarName]. selectTool ();
Toolbars [toolbarName]. refreshGroup ();
}
}
....
}

The simple meaning of this Code is that if ClientAction is customized, it is executed directly. If
No, the following call is constructed:

Function. Call ("Map [XXX] ('map1', '[ToolName]', showLoading, cursor ");

MapXxx (...) is actually a JS function provided by Map (in ESRI. ADF. UI. Map. js). There are a total of the following types:

MapDragImage = ESRI. ADF. MapTools. MapDragImage = function (mapid, mode, showLoading, cursor );
MapDragRectangle = ESRI. ADF. MapTools. DragRectangle = function (mapid, mode, showLoading, cursor );
MapBox = MapDragBox = ESRI. ADF. MapTools. DragRectangle;
MapPoint = ESRI. ADF. MapTools. Point = function (mapid, mode, showLoading, cursor );
MapLine = ESRI. ADF. MapTools. Line = function (mapid, mode, showLoading, cursor, vectorToolbarState );
MapPolyline = ESRI. ADF. MapTools. Polyline = function (mapid, mode, showLoading, cursor, vectorToolbarState );
MapPolygon = ESRI. ADF. MapTools. Polygon = function (mapid, mode, showLoading, cursor, vectorToolbarState );
MapDragCircle = MapCircle = ESRI. ADF. MapTools. Circle = function (mapid, mode, showLoading, cursor, vectorToolbarState );
MapDragOval = MapOval = ESRI. ADF. MapTools. Oval = function (mapid, mode, showLoading, cursor, vectorToolbarState );

Now we use MapDragRectangle () for analysis:

MapDragRectangle = ESRI. ADF. MapTools. DragRectangle = function (mapid, mode, showLoading, cursor)
{
Var map = $ find (mapid );
If (! Map) {map = Pages [mapid];}
If (ESRI. ADF. UI. Map. isInstanceOfType (map ))
{
If (mode = 'mapzoomin ')
{
Map. set_mouseMode (ESRI. ADF. UI. MouseMode. ZoomIn );
}
Else if (mode = 'mapzoomout ')
{
Map. set_mouseMode (ESRI. ADF. UI. MouseMode. ZoomOut );
}
Else
{
Var onComplete = Function. createDelegate (map, function (geom ){
Var geomString = geom. get_xmin () + ':' + geom. get_ymin () + '|' + geom. get_xmax () + ':' + geom. get_ymax ();
This. doCallback ('eventarg = DragRectangle & coords = '+ geomString +' & '+ mapid +' _ mode = '+ mode, this );
});

Map. getGeometry (ESRI. ADF. graphics. shapeType. envelope, onComplete, function () {map. _ activatemlmode = null;}, ESRI. ADF. mapTools. lineColor, ESRI. ADF. mapTools. fillColor, cursor, true );
Map. _ activatemlmode = mode;
}
..
}
}
...
};

When the Tool Name Is MapZoomIn and MapZoomOut, Map provides internal support. Otherwise, perform some operations.
Then, the operation information is sent to the Server through doCallback. The so-called execution of some operations, in fact
Is to draw a picture, by calling map. getGeometry (..., onComplete,...) to execute, after the execution is complete,
OnComplete is executed.

Var onComplete = Function. createDelegate (map, function (geom)
{
Var geomString = geom. get_xmin () + ':' + geom. get_ymin () + '|' + geom. get_xmax () + ':' + geom. get_ymax ();
This. doCallback ('eventarg = DragRectangle & coords = '+ geomString +' & '+ mapid +' _ mode = '+ mode, this );
});

After the operation is completed, map constructs the geom instance of the graph and serves as the onComplete () parameter. Pass on
In this case, we simply execute map. doCallback () to send the information back to the Server.

Map. doCallback () uses an important internal variable callbackFunctionString. The value of this variable is determined
The ESRI. ArcGIS. ADF. Web. UI. WebControls. WebControl Control on the Server side is generated to see its generated code:

Protected internal virtual string CallbackFunctionString
{
Get
{
If (this. RequiresPartialPostback)
{
This. callbackFunctionString = string. format ("_ esriDoPostBack ('{0}', '{1}', argument, ESRI. ADF. system. processMSAjaxCallbackResult, context) ", this. uniqueID, this. clientID );
}
Else
{
// Generate the statement: WebForm_DoCallback ('_ page', argument, ESRI. ADF. System. processCallbackResult, context, postBackError, true );

This. callbackFunctionString = this. Page. ClientScript. GetCallbackEventReference (this, "argument", "ESRI. ADF. System. processCallbackResult", "context", "postBackError", true );

}

Return this. callbackFunctionString;
}
}

When is RequiresPartialPostback TRUE? That is, when there is
In ScriptManager, the value is TRUE and partial Postback is executed. If there is no ScriptManager,
Callback will be executed. Through the above code, I know that if it is postback, execute:
__
_ EsriDoPostBack (this. UniqueID, this. ClientID, argument, ESRI. ADF. System. ProcessMSAjaxCallbackResult, context)

For callback, run the following command:

WebForm_DoCallback ('_ page', argument, ESRI. ADF. System. processCallbackResult, context, postBackError, true );

Whether it is Postback or Callback, after the information is sent to the server, it will be processed by the server, and then
Then return the information to the client, which is processed by the JS function defined in CallbackFunctionString. If it is postback,
ESRI. ADF. System. ProcessMSAjaxCallbackResult () is used for processing. Otherwise, ESRI. ADF. System. processCallbackResult () is used for processing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.