Custom TOC Renderer


Purpose
This sample shows how to create a custom toc renderer in JavaScript and use it within a Web ADF Java application.
 
The application will open one map control and two TOC controls. The one on the left is the TOC with custom renderering by custom xsl file. It looks like a legend with no behavior added to it. The one on the right is the TOC that is the same as map viewer application.

How to use

See How to use ArcGIS samples for help on running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

Custom TOC Renderer
  1. This sample shows how to create a custom toc renderer in JavaScript and use it within a Web ADF Java 10.0 application. The application will open one map control and two TOC controls. The one on the left is the TOC with custom renderering by custom xsl file. It looks like a legend with no behavior added to it. The one on the right is the TOC that is the same as map viewer application.
  2. Create and start an ArcGIS map server object. You may use any data, map configuration file, and server object name. If you wish to match the Web application in the Developer Help, create a server object named 'usa' from the map configuration file at %AGSDEVKITJAVA%\java\samples\data\mxds\usa.mxd.
  3. There are two ways to build the sample. You can either use ArcGIS Ant or Eclipse plugin. To use Ant, at command line, browse to %AGSDEVKITJAVA%\java\samples\customTocRenderer, type arcgisant build, follow the command prompt to finish the build. There will be a directory called build under the sample root folder, inside there will be a war file. Deploy the war file into Tomcat.
  4. The other way to build the sample is to use Eclipse. Open Eclipse, File - New Project - ESRI Templates - Web ADF Samples.
  5. Choose the Custom TOC Renderer
  6. Go through the wizard to finish building the sample.
  7. Run the sample web application on server.
  8. You can also export the application as war file and deploy to other supported application server.
  9. Open http://<host>:<port>/<appname>/map.jsf
  10. The application will open with 1 map control, with 2 toc controls
  11. The toc control on the left is the toc with the custom renderer. It is a simple toc, similar to a legend, with no behavior added to it.


Download the files for Java
customTocRenderer.jsp Lays out controls on page, with toc tag using custom xsl file to define custom toc renderer
customTocRenderer.js Defines custom toc renderer for toc control
customTocRenderer.xsl Includes custom javascript file and set toc renderer for toc




Development licensing Deployment licensing
Server Server