Building and Extending Tasks for ArcGIS …...ESRI Developer Summit 2008 1 David Cardella Keyur Shah...
Transcript of Building and Extending Tasks for ArcGIS …...ESRI Developer Summit 2008 1 David Cardella Keyur Shah...
ESRI Developer Summit 2008ESRI Developer Summit 2008 11
David CardellaDavid CardellaKeyur ShahKeyur ShahShu SangShu Sang
Building and Extending Tasks for ArcGIS Building and Extending Tasks for ArcGIS ServerServer——Java Web ApplicationsJava Web Applications
Schedule
• 75 minute session– 60 – 65 minute lecture– 10 – 15 minutes Q & A following the lecture
• Cell phones and pagers
• Please complete the session survey – we take your feedback very seriously!
ESRI Developer Summit 2008ESRI Developer Summit 2008
Introductions
• Who are we?– Members of the Java Server Development team
• Who are you?– Current ArcIMS developers?– New to ArcGIS Server?– Current ArcGIS Server developers?– JSF Developers?
ESRI Developer Summit 2008ESRI Developer Summit 2008
Session agendaSession agenda
•• Overview of tasks and the task frameworkOverview of tasks and the task framework•• Build a custom taskBuild a custom task
–– Implement a custom taskImplement a custom task–– Implement parameters, commands (actions) and tools in the Implement parameters, commands (actions) and tools in the
tasktask–– Customize the look and feel of the taskCustomize the look and feel of the task
•• Print and edit taskPrint and edit task–– IntroductionIntroduction–– Customizing the edit taskCustomizing the edit task
ESRI Developer Summit 2008ESRI Developer Summit 2008
55
Web ADF TasksWeb ADF Tasks
•• Tasks are objects that encapsulate business logic Tasks are objects that encapsulate business logic •• Configurable from ManagerConfigurable from Manager•• Out of the box tasksOut of the box tasks
–– MapToolsMapTools–– Geoprocessing Geoprocessing –– Search by attributesSearch by attributes–– EditingEditing–– Predefined queryPredefined query–– Find placeFind place–– Print (9.3)Print (9.3)
•• Custom tasksCustom tasks
ESRI Developer Summit 2008ESRI Developer Summit 2008
Task UITask UI
Task panelTask panel
Results panel
Results panel
Result Detailspanel
Result Detailspanel
77
DemoDemo
•• DemoDemo–– Search Attributes taskSearch Attributes task
ESRI Developer Summit 2008ESRI Developer Summit 2008
88
Task frameworkTask framework
•• Allows custom functionality to be implementedAllows custom functionality to be implemented•• TasksTasks
–– Objects that encapsulate business logicObjects that encapsulate business logic–– Can contain one or many commands or toolsCan contain one or many commands or tools
•• AdvantagesAdvantages–– Tight integration with the ADFTight integration with the ADF
•• Event handling with commands (actions) and toolsEvent handling with commands (actions) and tools•• UI is implemented for youUI is implemented for you
–– Good way to encapsulate related functionalityGood way to encapsulate related functionality–– Task development is similar to implementing a standard Task development is similar to implementing a standard JavaBeanJavaBean
•• What are we going to do?What are we going to do?–– Extend the Task Framework by implementing a custom task (action Extend the Task Framework by implementing a custom task (action
and tool)and tool)
ESRI Developer Summit 2008ESRI Developer Summit 2008
99
Steps to implement a custom taskSteps to implement a custom task
1.1. Create a standard Java ClassCreate a standard Java Class–– Signature of method dictatesSignature of method dictates
a command or tool a command or tool
2.2. Register the Java class as a managed beanRegister the Java class as a managed beanin the facesin the faces--configconfig
–– Makes it available in the ADFMakes it available in the ADF
3.3. Add a task tag to the Add a task tag to the jspjsp, with reference, with referenceto the managed beanto the managed bean
–– Visually displays the UI to the userVisually displays the UI to the user
ESRI Developer Summit 2008ESRI Developer Summit 2008
1010
Example: Implement a custom task (1)Example: Implement a custom task (1)
Create a standard Java ClassCreate a standard Java Class
(2A) Register Java class as a managed bean(2A) Register Java class as a managed bean
public class MyTask {
}
MyTask.java
<managed-bean>
<managed-bean-name>myTask</managed-bean-name>
<managed-bean-class>myPackage.MyTask</managed-bean-class>
<managed-bean-scope>none</managed-bean-scope>
</managed-bean>
faces-config.xml
ESRI Developer Summit 2008ESRI Developer Summit 2008
1111
Example: Implement a custom task (2)Example: Implement a custom task (2)
(2B) Add Java class as an attribute of web context(2B) Add Java class as an attribute of web context
Add the control to the Add the control to the jspjsp–– Value attribute = value of managedValue attribute = value of managed--beanbean--name in facesname in faces--configconfig
<a:task value="#{mapContext.attributes.myTask}" mapId="map1" />
xxx.jsp
<managed<managed--bean>bean>
<managed<managed--beanbean--name>name>mapContextmapContext</managed</managed--beanbean--name>name>
. . .. . .
<property<property--name>name>attributesattributes</property</property--name>name>
. . .. . .
<map<map--entry> <key>entry> <key>myTaskmyTask</key></key>
<value>#{<value>#{myTaskmyTask}</value>}</value>
faces-config.xml
ESRI Developer Summit 2008ESRI Developer Summit 2008
1212
Anatomy of a taskAnatomy of a task
•• ParameterParameter–– Provides inputs to a taskProvides inputs to a task–– Examples: Layer name, zoom factorExamples: Layer name, zoom factor
•• Command (action)Command (action)–– Executes business logic without user interaction with the mapExecutes business logic without user interaction with the map–– Example: Zoom to full extentExample: Zoom to full extent
•• ToolTool–– Requires user interaction with the mapRequires user interaction with the map–– Requires clientRequires client--side actionside action–– Examples: Identify, dynamic navigation (e.g., Zoom In/Out)Examples: Identify, dynamic navigation (e.g., Zoom In/Out)
ESRI Developer Summit 2008ESRI Developer Summit 2008
1313
Example: Add parameters to a custom taskExample: Add parameters to a custom task
•• Parameters Parameters –– Provide inputs for the taskProvide inputs for the task
public class BufferTask {
double bufferDistance = 40;
public double getBufferDistance() { return bufferDistance; }
public void setBufferDistance(double bufferDistance) {. . .}
String selectLayer;
public String getSelectLayer() { return selectLayer; }
public void setSelectLayer(String selectLayer) {. . .}
public Map getSelectLayers() {return selectLayers;}
}
public class BufferTask {
double bufferDistance = 40;
public double getBufferDistance() { return bufferDistance; }
public void setBufferDistance(double bufferDistance) {. . .}
String selectLayer;
public String getSelectLayer() { return selectLayer; }
public void setSelectLayer(String selectLayer) {. . .}
public Map getSelectLayers() {return selectLayers;}
}
BufferTask.java
A ESRI Developer Summit 2008ESRI Developer Summit 2008
1414
Example: Add a command to a custom taskExample: Add a command to a custom task
•• Add a method with Add a method with TaskEventTaskEventas argument as argument –– ((com.esri.adf.web.faces.eventcom.esri.adf.web.faces.event))–– Gives accessGives access
to WebContextto WebContext public class NavigationTask {
public void zoom(TaskEvent event) { . . .
}
}
public class NavigationTask {
public void zoom(TaskEvent event) { . . .
}
}
NavigationTask.java
A ESRI Developer Summit 2008ESRI Developer Summit 2008
1515
DemoDemo
•• DemoDemo–– Build a custom task that contains a parameter and a commandBuild a custom task that contains a parameter and a command
ESRI Developer Summit 2008ESRI Developer Summit 2008
1616
The task architectureThe task architecture
A
TaskContolTask Class
Metadata classes(TaskInfo)
ParamDescriptorsActionDescriptorsToolDescriptors
TaskIntrospector
ESRI Developer Summit 2008ESRI Developer Summit 2008
1717
TaskInfoTaskInfo explainedexplained
•• TaskInfoTaskInfo–– Returns description objects of the taskReturns description objects of the task
package com.esri.adf.web.data.tasks;
public interface TaskInfo {
TaskDescriptor getTaskDescriptor();
TaskParamDescriptorModel[ ] getParamDescriptors();
TaskActionDescriptorModel[ ] getActionDescriptors();
TaskToolDescriptorModel[ ] getToolDescriptors();
TaskLayout[ ] getTaskLayout();
}
package com.esri.adf.web.data.tasks;
public interface TaskInfo {
TaskDescriptor getTaskDescriptor();
TaskParamDescriptorModel[ ] getParamDescriptors();
TaskActionDescriptorModel[ ] getActionDescriptors();
TaskToolDescriptorModel[ ] getToolDescriptors();
TaskLayout[ ] getTaskLayout();
}
TaskInfo.java
ESRI Developer Summit 2008ESRI Developer Summit 2008
TaskInfo explained (cont')
package java.beans;
public interface BeanInfo {
BeanDescriptor getBeanDescriptor();
PropertyDescriptor[ ] getPropertyDescriptors();
MethodDescriptor[ ] getMethodDescriptors();
. . .
}
package java.beans;
public interface BeanInfo {
BeanDescriptor getBeanDescriptor();
PropertyDescriptor[ ] getPropertyDescriptors();
MethodDescriptor[ ] getMethodDescriptors();
. . .
}
BeanInfo.java
• BeanInfo– Returns description objects of the bean
ESRI Developer Summit 2008ESRI Developer Summit 2008
1919
Adding tools to a custom taskAdding tools to a custom task
•• Tools execute business logic based onTools execute business logic based onuser interaction with a mapuser interaction with a map–– Both clientBoth client--side and serverside and server--side actionsside actions
Add method with Add method with MapEventMapEvent as argumentas argumentCreate a Create a TaskInfoTaskInfo classclassProvide a Provide a TaskToolDescriptorTaskToolDescriptor
Interact with MapInteract with Map
Client InfoClient Info
A
MapEvent
Task Class
ESRI Developer Summit 2008ESRI Developer Summit 2008
2020
Example: Add a tool to a custom task (1)Example: Add a tool to a custom task (1)
Add method with Add method with MapEventMapEvent as argument as argument
public class MyTask {
public void selectCountries(MapEvent event) {
. . .
}
}
public class MyTask {
public void selectCountries(MapEvent event) {
. . .
}
}
MyTask.java
A ESRI Developer Summit 2008ESRI Developer Summit 2008
2121
MapEventMapEvent explainedexplained
•• MapEventMapEvent ((com.esri.adf.web.faces.eventcom.esri.adf.web.faces.event))–– Gives access to important informationGives access to important information
•• WebContext and WebContext and WebGeometryWebGeometry
–– Type of geometry depends on user action on clientType of geometry depends on user action on client
MapEvent WebGeometry
WebPoint
WebPolygon
WebExtent . . .
ESRI Developer Summit 2008ESRI Developer Summit 2008
2222
Example: Add a tool to a custom task (2)Example: Add a tool to a custom task (2)
Create a Create a TaskInfoTaskInfo classclass–– Extend Extend SimpleTaskInfoSimpleTaskInfo
public class MyTaskInfo extends SimpleTaskInfo {
. . . .
}
public class MyTaskInfo extends SimpleTaskInfo {
. . . .
}
MyTaskInfo.java
ESRI Developer Summit 2008ESRI Developer Summit 2008
2323
Example: Add a tool to a custom task (3)Example: Add a tool to a custom task (3)
Provide a Provide a TaskToolDescriptorTaskToolDescriptor–– ClientClient--side action: Controlled by JavaScript functionsside action: Controlled by JavaScript functions
•• EsriMapRectangleEsriMapRectangle, , EsriMapPanEsriMapPan, , EsriMapPointEsriMapPoint, etc., etc.
public class MyTaskInfo extends SimpleTaskInfo {
public TaskToolDescriptorModel[ ] getToolDescriptors() {
return new TaskToolDescriptor[ ] {
new TaskToolDescriptor(MyTask.class, “select", “Select", “EsriMapRectangle”)};
}
}
public class MyTaskInfo extends SimpleTaskInfo {
public TaskToolDescriptorModel[ ] getToolDescriptors() {
return new TaskToolDescriptor[ ] {
new TaskToolDescriptor(MyTask.class, “select", “Select", “EsriMapRectangle”)};
}
}
MyTaskInfo.java
ESRI Developer Summit 2008ESRI Developer Summit 2008
2424
DemoDemo
•• DemoDemo–– Implement a custom select toolImplement a custom select tool–– Display on graphics layerDisplay on graphics layer
ESRI Developer Summit 2008ESRI Developer Summit 2008
2525
Task resultsTask results
•• Task operations mayTask operations maygenerate resultsgenerate results–– Tools or commandsTools or commands
•• Results can be arbitraryResults can be arbitraryJava objectsJava objects–– Query resultsQuery results–– Address candidatesAddress candidates–– Geoprocessing resultsGeoprocessing results
•• Types of informationTypes of information–– Display textDisplay text–– Result detailsResult details–– Actions that can be performed on resultsActions that can be performed on results
A ESRI Developer Summit 2008ESRI Developer Summit 2008
2626
addResultsWithActionArraypublic ResultNode addResultsWithActionArray(java.lang.String groupHeader,
java.util.List results,java.lang.String displayNameMethodName,java.lang.String detailsMethodName,java.lang.String[] actionMethodsNames)
Task results (coTask results (cont')nt')
•• WebResultsWebResults–– Container object for resultsContainer object for results–– Attribute to the ContextAttribute to the Context–– Results displayed as Results displayed as
tree by defaulttree by default–– Toc control is reToc control is re--usedused
•• com.esri.adf.web.data.resultscom.esri.adf.web.data.results
A ESRI Developer Summit 2008ESRI Developer Summit 2008
2727
DemoDemo
•• DemoDemo–– Display attributes in the task frameworkDisplay attributes in the task framework
ESRI Developer Summit 2008ESRI Developer Summit 2008
2828
Inside the Inside the TaskInfoTaskInfo InterfaceInterface
•• Why implement a custom a Why implement a custom a TaskInfoTaskInfo class? class? –– LayoutLayout
•• Position of parameters, commands and toolsPosition of parameters, commands and tools
–– Titles/textTitles/text•• Name of task on title barName of task on title bar•• Messages in the task UIMessages in the task UI
–– IconsIcons•• Commands and toolsCommands and tools
ESRI Developer Summit 2008ESRI Developer Summit 2008
2929
Inside the Inside the TaskInfoTaskInfo InterfaceInterface
•• Task class contains business logicTask class contains business logic•• TaskInfoTaskInfo class contains metadataclass contains metadata•• TaskInfoTaskInfo class changes look class changes look
and feel without affecting any and feel without affecting any business logicbusiness logicpackage com.esri.adf.web.data.tasks;
public interface TaskInfo {
getTaskDescriptor();
getParamDescriptors();
getActionDescriptors();
getToolDescriptors();
getTaskLayout();
}
package com.esri.adf.web.data.tasks;
public interface TaskInfo {
getTaskDescriptor();
getParamDescriptors();
getActionDescriptors();
getToolDescriptors();
getTaskLayout();
}
TaskInfo.java
ESRI Developer Summit 2008ESRI Developer Summit 2008
3030
DemoDemo
•• Implement a custom Implement a custom TaskInfoTaskInfo classclass
ESRI Developer Summit 2008ESRI Developer Summit 2008
Print and Edit tasks
• Print task (9.3)– Popular request– Map, title, TOC– Include results– Customize format, look and feel
of print page
• Edit task– Edit layer served through SDE– Ability to set edit settings– More customization options at 9.3
• Customize UI• Extend existing business logic
ESRI Developer Summit 2008ESRI Developer Summit 2008
Anatomy of the Editor TaskAnatomy of the Editor Task
3232
<div style="display:none"><div id="esri_editVersionDiv">
<jsp:include page="version.jsp" /></div><div id="esri_editDiv">
<jsp:include page="edit.jsp" /></div><div id="esri_editSettingsDiv">
<jsp:include page="settings.jsp" /></div><div id="esri_editXYDiv">
<jsp:include page="xy.jsp" /></div></div>
<div style="display:none"><div id="esri_editVersionDiv">
<jsp:include page="version.jsp" /></div><div id="esri_editDiv">
<jsp:include page="edit.jsp" /></div><div id="esri_editSettingsDiv">
<jsp:include page="settings.jsp" /></div><div id="esri_editXYDiv">
<jsp:include page="xy.jsp" /></div></div>
ESRI Developer Summit 2008ESRI Developer Summit 2008
MapViewer.jsp
Anatomy of the Editor TaskAnatomy of the Editor Task
3333
<a:buttonid="select"mapId="map1"clientAction="EsriMapRectangle" serverAction="#{mapContext.attributes.mapEditor.select}"defaultImage="./images/tasks/editing/selectfeature.gif" hoverImage="./images/tasks/editing/selectfeatureU.gif" selectedImage="./images/tasks/editing/selectfeatureD.gif“disabledImage="./images/tasks/editing/selectfeatureX.gif" toolTip="EditTask.TaskInfo.Tip.selectfeatures“/>
<a:buttonid="select"mapId="map1"clientAction="EsriMapRectangle" serverAction="#{mapContext.attributes.mapEditor.select}"defaultImage="./images/tasks/editing/selectfeature.gif" hoverImage="./images/tasks/editing/selectfeatureU.gif" selectedImage="./images/tasks/editing/selectfeatureD.gif“disabledImage="./images/tasks/editing/selectfeatureX.gif" toolTip="EditTask.TaskInfo.Tip.selectfeatures“/>
ESRI Developer Summit 2008ESRI Developer Summit 2008
Edit.jsp
• How can we customize the editing task?
DemoDemo
•• Customize the editing taskCustomize the editing task–– Show the outShow the out--ofof--the box Editing task the box Editing task –– Customize the UICustomize the UI–– Extend the business logic of the Select toolExtend the business logic of the Select tool
3434ESRI Developer Summit 2008ESRI Developer Summit 2008
In ConclusionIn Conclusion……
•• Other recommended sessionsOther recommended sessions– ArcGIS Server for ArcIMS Developers
• Tuesday 1:00 in Primrose A• Thursday 1:30 in Catalina/Madera
– Building Java Applications Using the ArcGIS Server Web ADF and AJAX• Tuesday 4:30 in Smoketree A-E• Thursday 10:15 in Primrose C/D
– Developing Advanced Java Web Applications• Wednesday 1:00 in Smoketree A-E
– Implementing Security for ArcGIS Server—Java Solutions• Thursday 10:15 in Pasadena/Sierra/Ventura
ESRI Developer Summit 2008ESRI Developer Summit 2008
In ConclusionIn Conclusion……
•• All sessions are recorded and will be available on EDNAll sessions are recorded and will be available on EDN–– Slides and code will also be availableSlides and code will also be available
•• Please fill out session surveys!Please fill out session surveys!
•• Still have questions?Still have questions?1.1.Tech talk, Demo Theatres, Meet the TeamTech talk, Demo Theatres, Meet the Team2.2.““Ask a DeveloperAsk a Developer”” link on web pagelink on web page
•• www.esri.com/devsummit/techquestionswww.esri.com/devsummit/techquestions
ESRI Developer Summit 2008ESRI Developer Summit 2008