How to add a command or tool


Summary This topic shows you how to add a predefined tool or command to a Web Application Developer Framework (ADF) application.

In this topic


Adding a command

A command is an element on a JavaServer Pages (JSP) page that triggers a server-side action without further interaction on the client.
The steps to add a command are as follows:
  1. Add a <a:command> tag to the JSP page.
  2. Specify the actionListener of the command.
  3. Set the attributes of the command tag.
In the Simple ArcGIS Server Web ADF Java Platform application (sample application), there is one command, Zoom to Full Extent. When you click the Zoom to Full Extent button, a method is called on the server.
The following code sample shows how to add the predefined Pan Right command to a Web ADF application. The Pan Right command allows you to pan right each time you click the Pan Right command button.
[Java]
 < a: command >  < f: actionListener type = 
     "com.esri.adf.web.faces.event.DirectionalPanListener" /  >  < f: attribute name
     = "contextId" value = "mapContext" /  >  < f: attribute name = "direction"
     value = "right" /  >  <  / a: command >
When adding the Pan Right command, you must set the contextId and direction attributes as well as specify the actionListener com.esri.adf.web.faces.event.DirectionalPanListener.  Additional attributes of the command can be set if necessary, such as the image for the command button.

Adding a tool

A tool has additional client-side interaction before calling a method on the server.
The steps to add a tool are as follows:
  1. Add a <a:tool> tag to the JSP page.
  2. Specify the clientAction and serverAction.
  3. Set the attributes of the tool tag.
An example of a tool in the sample application is the Zoom to Rectangle tool. When you click the Zoom to Rectangle button and drag a rectangle over the area of the map you want to zoom to, a method is called on the server.
The following code sample shows how to add the predefined Pan tool to a Web ADF application. The Pan tool allows you to pan the map each time you click the Pan tool button and drag the map.
[Java]
 < a: tool id = "pan" defaultImage = "images/pan.gif" hoverImage = "images/panU.gif"
     selectedImage = "images/panD.gif" clientAction = "EsriMapPan" serverAction = 
     "com.esri.adf.web.faces.event.PanToolAction" clientPostBack = "true" /  >
In this code sample, the id attribute is the ID of the tool. The image attributes specify the images for the tool button in different status. clientAction specifies the client action and serverAction specifies the server action once the client action is complete. Finally, clientPostBack specifies if Asynchronous JavaScript and XML (AJAX) is supported in this tool operation.


See Also:

Custom commands and tools