ArcGIS Server Java ADF case 14

Source: Internet
Author: User

Command, tool, and button

In this chapter, we will mainly discuss the children and relatives of toolbar, including two children: command and tool, and a relative: button. They are the first step to expand the WebGIS functions based on the ADF. They allow you to add custom buttons to the map toolbar to execute specific functions.

In chapter 3, we listed toolbar as one of the common components of the ADF, but it is different from other components such as map, TOC, overview, and so on. We open the context-attributes.xml configuration file and we can find that, map, TOC, overview, and other components all have corresponding an definitions, but the toolbar does not -- because it does not need to bind a "webtoolbar" object on the server side to record the status information of the toolbar.

Let's take a look at the usage of these components.

1 command

Command is displayed as a button in the toolbar. When you click this button, the ADF will immediately perform some operations. Clicking command is equivalent to directly sending a command to the ADF. It does not change the status of the current map. For example, the current map is roaming, and it is still roaming when you click command to operate the map.

The most typical command is the "map full graph" function. When you click it, the current map is scaled to the full graph display. The following code defines such a command.


From this code, we can see that the most critical usage of command is to define its sub-element "F: actionlistener ", its "type" attribute points to a listener class that implements certain functions (note that it is not an object ). The "zoomfullextentlistener" here is the listener that comes with the ADF. Of course, this class can also be any class that implements the actionlistener interface. In the following cases, we will implement our own listener class.

Next let's take a look at two command definitions that are slightly different. The two commands provide the "back" and "Forward" buttons. When you click "back", the map will return to the range of the previous view; when you click "forward", the map will go to the next view range. The following code defines these two commands.


The listener is not used here, but the action attribute of command is used. This property will bind a server-side object method. When you click this command, the ADF will call this server-side method. The "backward" and "Forward" functions mainly use the extenthistory object in the ADF, which can maintain the view range history of the map. Below is the definition in context-attributes.xml:


When we click the "back" button, the ADF will call the doprevious method of the "History" object on the server side, so the map will switch to the previous view. It is similar to clicking "forward. In addition, the disabled attributes of the two commands are bound to the canundo and canredo attributes of the "History" object respectively. This is also easy to understand. When the map is already the latest view, of course, you cannot click the forward button. The canredo attribute value of history is true, so the forward button is unavailable.

To sum up, we mainly introduce the two definitions and usage of command. One defines the listener class as the sub-element of command, and the other binds the server method to the action attribute of command. For custom commands, it is easier to use listeners.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.