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 Context Menu
- This sample shows how to use AJAX within a Web ADF Java 10.0 application and how to use the postback framework. Two Java classes, one handles request from TOC context menu and store result to web context and is added the TOC content handler, the other implements the AJAXRenderer interface and is added as one of the AJAX renderers. Client side JavaScript handles postback call back. Right click on a layer in TOC; you will see a new menu item called “Show Layer Attribute” in the context menu. Selecting that will show attribute of the visible features in that layer.
- 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\customTocContextMenu, 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.
- The other way to build the sample is to use Eclipse. Open Eclipse, File - New Project - ESRI Templates - Web ADF Samples.
- Choose the Custom TOC Context Menu
- Go through the wizard to finish building the sample.
- Run the sample web application on server.
- You can also export the application as war file and deploy to other supported application server.
- Open http://<host>:<port>/<appname>/map.jsf
- Zoom into an area of the map such that not too many features are visible
- Right click on a layer in toc and select the 'Show Layer Attributes' menu item
- This should process your request and display the attributes for all features in that layer currently within the visible extent
Download the files for Java
layerAttributes.jsp | This page lays out the controls and drop down on the page |
layerAttributes.js | The registering and function to handle postback call back and defined |
ajax-renderers.xml | Add the LayerAttributesRenderer to the list of AJAX renderers |
ags-functionalities.xml | Add the ShowAGSLayerAttributes class as toc content handler |
JavaSource\com\esri\arcgis\sample\layerattributes\LayerAttributesRenderer.java | Implements the AJAXRenderer interface and if attribute data is available, renders the attribute data as xml |
JavaSource\com\esri\arcgis\sample\layerattributes\ShowAGSLayerAttributes.java | Handles request from toc context menu and stores results to web context |
Development licensing | Deployment licensing |
---|---|
Server | Server |