ArcGIS Server Java-custom functionality

Source: Internet
Author: User

In this section, we implement a gisfunctionality to encapsulate the previously implemented function to enlarge the map by 5 times.
First, create a functionality class and add it to the ADF application. Previously, we often define classes and configuration files by directly editing the Code. This is mainly to help you understand the configuration of the ADF application and the relationship between each element. Now you have some knowledge, so we try to save some trouble. Use the Eclipse plug-in of ArcGIS to do this.
Let's open the eclipse menu [ArcGIS]-[Class templates]-[functionality ], fill in the package name and Class Name of the functionality that we want to implement in the new window, the name of the instantiated managed bean, and the registered resource, after the configuration is complete, the ADF automatically creates a class that implements the gisfunctionality interface, instantiates the class, and registers it to the configuration file of the ADF application.

Figure 26 Add a custom functionality using the ArcGIS ide plug-in

Next we need to encode the newly generated functionality class to implement our own functions:
Public class zoom5functionality implements gisfunctionality
{
Private gisresource resource;
Public void zoomin5 ()
{
Webcontext = resource. getwebcontext ();
Webcontext. getwebmap (). getcurrentextent (). Expand (0.2 );
Webcontext. Refresh ();
}
Public void zoomout5 ()
{
Webcontext = resource. getwebcontext ();
Webcontext. getwebmap (). getcurrentextent (). Expand (5 );
Webcontext. Refresh ();
}
Public void initfunctionality (gisresource Resource) {This. Resource = resource ;}
Public void destroyfunctionality (){}
Public gisresource getresource () {return this. Resource ;}
}
In this way, zoom5functionality has two functions: zoomin5 and zoomout5, which correspond to 5 times of map enlargement and 5 times of map reduction respectively. Next, let's put a command on the page to call zoomin5 function of zoom5functionality:
<A: command ID = "zoomin"
Defaultimage = "images/tasks/maptools/zoomin.png"
Hoverimage = "images/tasks/maptools/zoominu.png"
Selectedimage = "images/tasks/maptools/zoomind.png"
Clientpostback = "true">
<F: actionlistener type = "wuyf. zoominlistener"/>
</A: Command>
Of course, the server also needs a listener to process the command request and actually call the zoom5functionality method:
Public class zoominlistener implements actionlistener
{
Public void processaction (actionevent event) throws abortprocessingexception
{
Webcontext = webutil. getwebcontext (event. getcomponent ());
Gisresource resource = webcontext. getresourcebyid ("agsws1 ");
Zoom5functionality functionality =
(Zoom5functionality) resource. getfunctionality ("zoom5functionality ");
Functionality. zoomin5 ();
}
}
Maybe you may think this is a little too much. Why should a simple function be encapsulated with functionality? Of course, this is mainly because the function demonstrated here is too simple. If you have complicated logic to encapsulate and want to flexibly configure some resources to require this function, some resources are not needed, then Functionality can help you a lot.
Here, we also need to mention the initfunctionality method of gisfunctionality. This method is called when functionality is initialized. In this case, you can also perform operations on gisresource, for example, select the layer to be displayed based on permission verification.

This article is transferred from:

Customize functionality to 5 times larger than a map [Case Study]

Other links:

Server Java lecture custom functionality

Implement User permission control using custom functionality

Custom functionality

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.