ArcGIS Server brushless callback)

Source: Internet
Author: User
Tags call back

From: http://bbs.esrichina-bj.cn/ESRI/thread-55413-1-1.html

To develop ArcServer, let's not talk about such things as ADF and AO. First of all, we need to understand how the map is refresh and how to call back the map. Before proceeding, we will introduce an interface in. net Framwork. System. Web. UI. ICallbackEventHandler, which is an interface for implementing page refreshing in. net, and ArcServer does not need to be refreshed by this interface.
There are two main methods to implement this interface:
1.
The string ICallbackEventHandler. GetCallbackResult () method returns the string to be sent to the client for parsing. The returned string must be parsed by the front-end JavaScript to be reflected on the front-end page.
2.
Void ICallbackEventHandler. RaiseCallbackEvent (string eventArgument) is mainly a background logic program, that is, the location of the main logic code running on the server. That is, in this method, obtain the strings to be returned to the client, assign these strings to a global variable, return them to the previous method, and return them to the client through the previous method. The eventArgument parameter is the message Parameter transmitted from the foreground, which is also the string format. Then, the server parses the string and executes the corresponding method.
The above is mainly about the server side. Next we will explain the client. On the client side, javaScript script code is used. This technology, once left empty, is the main character of today's ajax brushless technology.
There are three methods:

1.
Function getServerTime ()


{Var message = 'getservertime ';

Var context = 'page1 ';
<% = SCallBackFunctionInvocation %>

}
Script Execution entry method. For example, you can execute this method in a button click event. Message is the eventArgument parameter parsed on the server. Context is the control to be refreshed. The third line transfers the execution line to the server.
2.
FunctionprocessMyResult (returnmessage, context)
{Var timediv = document. getElementById ('timelabel ');

Timediv. innerHTML = returnmessage;

}
This method is used to parse the string returned by the server after the server code is executed. Returnmessage is the return string of the server, and context is the control to be refreshed after the previous string is passed in.

3.
Function postMyError (returnmessage, context)
{
Alert ("Callback Error:" + returnmessage + "," + context );
}

Client method that fails to be executed when the server executes the callback

So far, our callback client and the server have been connected. What is the connection between the client and the server? Is the global variable sCallBackFunctionInvocation. This is a global variable on the server. It is defined as sCallBackFunctionInvocation = Page. ClientScript. GetCallbackEventReference (this, "message", "processMyResult", "context", "postMyError", true );
The first parameter is the server Control that processes the client callback. This control must implement the ICallbackEventHandler interface and provide the RaiseCallbackEvent method.
The second parameter is transmitted from the client to the server. The server parses the parameter to obtain available information.
The third parameter is a script method of the client, which is used to accept the result returned by the server after processing, parse the result, and perform the corresponding action.
The fourth parameter is the client script information on the client before the callback is started. The script result is returned to the client event handler.

The fifth parameter is the script method executed after the callback task fails to be executed.
After the introduction, how can we use the brushless matter in ArcServer?
1.
In the tool.
This is the simplest and best to understand (a good understanding does not mean a thorough understanding ). In addition to the name, text display, and toolTip attributes of images in various States, the custom tool also includes ClinetAction and ServerAction. These two things are the key to this tool. As the name suggests, clientAction is the action triggered by the client, and ServerAction is the action triggered by the server. For example, to draw a line, ClinetAction must select polyLine. The server also chooses the class that inherits the ToolServerAction interface and writes the method to be executed by the server in this type of serverAction. When you execute this tool, you will call javaScript to draw a line. After the painting is complete, the system will take the result of the client to execute the draw line operation as a parameter to execute the code on the server side. After the callback is executed, the client script automatically parses the string returned by the server after execution. Then, refresh the corresponding interface.

But at the beginning and end, in this process, we do not seem to have written a javaScript code, that is, the Code executed by the client, who will parse the passed parameters and the string returned by the server? Originally, ArcServer defined some JavaScript code for us in advance. C: \ Inetpub \ wwwroot \ aspnet_client \ ESRI \ WebADF \ JavaScript, which is generally stored in this folder. The Code contains both the client line code and the code used to parse the string returned by the server. As long as the implementation of partial refresh of googleMap uses nearly lines of javaScript code, we can see the importance of JavaScript in WebGIS.
2.
Click the button and other common commands to call back and refresh
The difference between this method and the above method is that you need to write the parsing processing server to return the string, parse it yourself, and go to the client for execution, of course, the self-resolution here does not require us to parse all strings, such as the returned html code or javaSript script, and the browser can parse it, we can just leave these items to the browser.

The following describes how to construct the returned strings. to parse these strings on the client, you must have constructed rules, the server end that generates the string and the client that parses the string follow the string construction rule so that synchronization between the two ends can be achieved.
1.
First, the first constructor is to refresh the control with the ADF itself, such as TOC. These controls all have their own response string construction rules, and ESRI has been encapsulated for us. Therefore, you only need to call the CallBack. toString () method of the control and add it to the Map CallBack. The client automatically parses and refreshes the control to be refreshed.
2.
The second is to refresh other Asp.net controls. This is a little more complicated. We need to make these controls synchronously refresh with the ADF, and it is not something in the ADF itself. In this case, strings are constructed by ourselves. However, the constructed client can be parsed. The following is the string construction rule returned in the help of the ADF.

"Content"

Used to set the outerHTML property of an html element. the html element on the client defined by the CallbackResult controlType and controlID is completely replaced by the html content provided as a parameter in the object array (object []).

"Innercontent"

Used to set the innerHTML property of an html element. the content inside the html element on the client defined by the CallbackResult contains controlType and controlID is completely replaced by the html content provided as a parameter in the object array (object []).

"Image"

Used to set the src property of an image element. the source of the image element on the client defined by the CallbackResult contains controlType and controlID is changed to the url string provided as a parameter in the object array (object []).

"Javascript"

Used to execute JavaScript on the client. The CallbackResult contains controlType and controlID and set to null. The JavaScript code is provided as a parameter in the object array (object []).

"Content"

Set the outerHTML attribute of an HTML element. CallbackResult defines the type of the control to be operated. The ID is placed in the refreshed method parameter.

"Innercontent"

Defines the innerHTML attribute of an html object. Define the content to be displayed in the html element and the element type of the content to be replaced. The element ID is used as a parameter and placed in CallbackResult.
"Image"

This parameter is used to define the src (Resource) attribute of an image element. It defines the image resource and the image Element type and ID of the resource to be changed. Then, it is added to CallbackResult as a parameter.
"Javascript"

It is used to execute JavaScript on the client. The Parameter Element type and element number are both set to null. The javaScript code is added to CallbackResult as a parameter.

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.