Refresh method of webcontext
Tip: This section describes the internal implementation mechanism of the ADF, which has no impact on the use of the ADF. Skip this section if you are not interested.
When the refresh method of webcontext is called, the ADF synchronizes all related attributes in webcontext. For example, if I change the view range of webmap and then call the refresh method of webcontext, the ADF will notify weboverview and other objects in webcontext to synchronize relevant information, such as synchronously changing the view range. The above process is implemented by the observer mechanism in the background. When the ADF calls the refresh method of webcontext, it notifies all the webcontextobserver objects registered with webcontext to call its update method. Webcontextobserver interfaces include the following classes: awstocfunctionality, extenthistory, maptoolstask, printtask, routingtask, searchattributestask, webmap, weboverview, and webscalebar.
The above refreshes webcontext on the server side. However, after a command is clicked, how does the server update be output to the browser? Next let's start from the browser and learn in detail how command works.
The following is a command defined on the JSF page using the: Command tag in the previous section. Let's take a look at the corresponding output of this tag in the browser:
The above labels are output in the browser:
VaR zoomin = new esrimapserveraction ("zoomin ","");
Zoomin. clientpostback = true;
Zoomin. defaultimage = "/agsdemo/images/tasks/maptools/zoomin.png ";
Zoomin. hoverimage = "/agsdemo/images/tasks/maptools/zoominu.png ";
Zoomin. selectedimage = "/agsdemo/images/tasks/maptools/zoomind.png ";
Zoomin. isdisabled = false;
Zoomin. showloading = true;
Toolbar. addtoolitem (zoomin );
It can be seen that a command outputs the JavaScript Object esrimapserveraction, which is defined in "/webcontent/JS/esri_map.js. Open the definition of esrimapserveraction and you will find that when you click this command, the ADF will submit the current page. Of course, since we set the clientpostback attribute to true, interaction is performed through Ajax, the callback function is the processpostback function of esricontrols. esricontrols is defined in "/webcontent/JS/esri_core.js" and contains all the ADF client components.
Tip: the above section is very simple. It actually contains a lot of content. If you are interested, you can carefully study the related objects and call relationships in these JavaScript scripts.
The ADF has a postbackphaselistener on the server side to listen to all Ajax requests. If you are interested, you can unbind the library file "/webcontent/WEB-INF/lib/arcgis_webcontrols.jar, the phaselistener is defined in a META-INF under the "faces-config.xml" directory.
The parameter of the Ajax request has a "dopostback" value. When an Ajax request is sent to the server, postbackphaselistener listens to the request and finds the value "dopostback" to perform subsequent operations. After these operations are completed, postbackphaselistener uses the writeresponse method of ajaxutil to output Ajax responses to the requested browser.