Installing JavaScript Locally for ArcGIS for Server 10.2

Developer
4th October 2013

If you have ever installed JavaScript locally for ArcGIS Server 10.0/ArcGIS for Server 10.1 you would have learnt that the procedure involved downloading and installing the JavaScript libraries and SDK; changing the [HOSTNAME_AND_PATH_TO_JSAPI] in init.js and dojo.js files, then editing the rest.config file (10.0) or rest-config.properties file (10.1) – if you could remember where these files were stored.  Once done you could use JavaScript to see the services through the “http://[HOSTNAME]/arcgis/rest/services” pages without having to launch ArcGIS for Desktop or be connected to the Internet.

All went well until the release of JavaScript Version 3.2 when instead of one CSS file, a second one (esri.css) was required. However, there was no provision in the rest.config or rest-config.properties for a “css2” alias.  If you wanted to use JavaScript 3.2 or later locally for ArcGIS for Server 10.1 it also involved changing additional files such as mapserverJSAPI.jsp and imageserverJSAPI.jsp which could cause problems and is definitely NOT recommended, especially as you would need to update all individual machines in a cluster and once again after every service pack install; so you were stuck using JavaScript 3.1 online or offline.

At ArcGIS for Server 10.2 an alias of “css2” has been added to the rest-config.properties and JavaScript Version 3.3 is used as default.

 

[POINT TO NOTE: From Version 3.6 the JavaScript API is not available online on “http://serverapi.arcgisonline.com”. A new CDN URL “http://js.arcgis.com/API-VERSION/” is available for all JavaScript Versions from 3.0 onwards. Substitute the version number for API-VERSION, e.g. http://js.arcgis.com/3.7/.]

However, making changes to rest-config.properties does not work at ArcGIS for Server 10.2 and does not change the reliance on internet served JavaScript. 

There is a new administration capability which is used to change the parameters which is accessed through http://localhost:6080/arcgis/admin (or http://localhost/arcgis/admin if you have enabled the Web Adaptor for administrative access). Once you have logged on as administrator you are shown various options and you can then navigate through the pages to http://localhost/arcgis/admin/system/handlers/rest/servicesdirectory:

When the “edit” operation is selected the values for the parameters can be saved as shown below (obviously one would substitute the full domain path for localhost).

 

The JavaScript Version can be changed to the latest available (currently 3.7 released 27 September 2013) and all new capabilities exploited.

 

by Jim Sibbald

Developer