Today, I discovred FireBug.
It is three weeks into my new job, I started to get into ArcGIS Server ADF 9.2 beta 2 (final release is due out in the coming month).
Early this week, I found out from ESRI that the beta 2 do not support the Synchronous Call for their ADF controls. By default, all the controls use Asynchronous call. (ha, isn’t this fun, or not?!)
So I spent a whole day yesterday and find out that there are 3 types of Tool I can create for my Toolbar:
- a tool that ESRI ADF takes care of everyting
For something like Zoom In/Out, Pan (doesn’t need any customized server processing , not returnning any dataset either)
Client-Side data collection:
ESRI provides default action types (Point, DragRectangle…)
Server-Side data processing:
Using matching ESRI ADF avialable assembilies to take care the action.
Client Data passing to Server-Side
ADF take care that, I don’t have to worry a thing.
- a tool that ESRI ADF takes care the Client-Side while I take care of the Server-Side
For something like fixed-Zoom (do need customized server processing but still not returnning any dataset)
Client-Side data collection:
ESRI provides default action types (Point, DragRectangle…)
Server-Side data processing:
Write your own handler by Implementing IMapeServer..
Client Data passing to Server-Side
ADF pass-in the data as EventArgs and server-side can use it
Now comes the fun one!!! (AJAX)
For Map Identify or Measure Tool (do need customized server processing, and need to return either dataset)
Client-Side data collection:
Write my own JScript to caputuer user data (that’s not fun at all) and Trigger Call-Back to post data to server for processing
Server-Side data processing:
Write my own data processing and send results back to client for display
Client Data passing to Server-Side
Utilize ASP.NET Call-Back mechanism. XMLHTTP request.
I love AJAX approach for its customizability But I do hate to write tedious thick client-side Jscript. Considering there is not much documentation on ArcGIS Server 9.2 beta ADF yet. The existing documenation are half blank. And trying to figure out how to caputer the point data when when user drag a rectangle select on the map is no fun at all.
I struggled to get the MapIdentify and MapMeasure Tool to work in AJAX way. That’s after 4 hours pulling hair trying to figure out why the Call-Back didn’t result any data back. Gee, there are so many things can go wrong in between a click and the next click.
Is it
1) Not doing callback like it suppose to? OR
2) Does callback but the user data didn’t get pass on to server correctly?
3) Server got the data but didnt’ read it right?
4) Server somehow ignore the request and didnt’ process it?
5) Server didn’t find any data that can post back?
6) Post back data got lost in transaction?
7) …
Thanks god, instead of guessing around with no clue, I decide to find out HOW TO DEBUG AJAX. AJAX is faily new but not that new. Somebody must have done something to make everybody’s life much easier.
And in deed, there always somebody out there willing to do just that. Joe Hewitt’s FireBug (for FireFox) made my afternoon.
FireBug Console tracked every single xmlHTTP post (callbacks) and the Post and Response data. By reading the string sent to server and the results sent back to client, I found out that my MapMeasure tool (Polyline / Polygon) does the callbacks correctly but the data didn’t get processed on the server-side, thus no data to post back to client-side.
Important things I learned this week of trugging ghrough to get by:
-
If you are going to write a User Control doing AJX, be aware that the Client-Side ID is not going to be the same as Server-Side. (most ESRI samples using “Map1″, if it is in a control and when it got rendered on a page, the name will be “Control_Map1″ or it could be a random name.) But since Callback relies heavily on DIVID of that control, I really have to be carefully not hard-code any id…
-
When you put multiple tools in one control, each of them has its own callback signature and triggers different client-side JScript and when it got to server side, raised the callback, you have to find out which EventArg to use for switching to do different data processing.
It is by reading EventArgs that I discovered that I didn’t use the right EventArg Pair to decide when to do Identify and when to do Measure.
When the 9.2 final realease come out, will it come with full documentation?. (A half-done documentation is like showing my dog Sally a nice treat but not giving to her. She got anxious and pretty soon will pond on the patio door until she gets it)
Life needs to go on, even without documentation…