developing applications with arcgis server and the java ... · introductions • who am i?...
TRANSCRIPT
Developing Applications with Developing Applications with ArcGISArcGIS Server Server d h J Pl fd h J Pl fand the Java Platform and the Java Platform
Patrisha WellsPatrisha Wells
IntroductionsIntroductions
•• Who am I?Who am I?–– Instructor in the Washington DC regional officeInstructor in the Washington DC regional office
•• Who are you?Who are you?–– Current Current ArcGISArcGIS Server developers?Server developers?
NN A GISA GIS S d l ?S d l ?–– New New ArcGISArcGIS Server developers?Server developers?
•• Please turn OFF cell phones and paging devices.Please turn OFF cell phones and paging devices.
•• Please complete the session survey Please complete the session survey –– we take your feedback very we take your feedback very p yp y y yy yseriously!seriously!
AgendaAgenda
•• What is the Java Web ADF?What is the Java Web ADF?•• JSF ControlsJSF Controls•• Task FrameworkTask Framework
–– Built in tasksBuilt in tasks–– Custom tasksCustom tasks
•• Developer APIsDeveloper APIs
What you should already knowWhat you should already know
•• InternetInternet–– Internet development languages (Java, JSP, JavaScript, etc.)Internet development languages (Java, JSP, JavaScript, etc.)
Servers administration protocols accounts and securityServers administration protocols accounts and security–– Servers, administration, protocols, accounts, and securityServers, administration, protocols, accounts, and security•• ArcGISArcGIS ServerServer
–– Server components and architectureServer components and architectureH t th bli h d i i t d GIS iH t th bli h d i i t d GIS i–– How to author, publish, administer, and use GIS servicesHow to author, publish, administer, and use GIS services
•• ArcObjectsArcObjects–– COM COM –– Developer resourcesDeveloper resources
What is the Web ADF?What is the Web ADF?
•• Set of controls, tasks, and Web applications to enable creation of Set of controls, tasks, and Web applications to enable creation of GIS applicationsGIS applications
MultiMulti source Web controlssource Web controlsWeb Server
–– MultiMulti--source Web controlssource Web controls–– Developer librariesDeveloper libraries–– AJAXAJAX--enabled JavaScript libraryenabled JavaScript library
JSP Tag librariesJSP Tag libraries
Task Framework
TasksWeb Browser
Web ADF JavaScript
Web Controls
Web ADF JavaScript
–– JSP Tag librariesJSP Tag libraries–– Task FrameworkTask Framework–– TemplatesTemplates
Eclipse andEclipse and NetBeansNetBeans
Web ADF consolidation classes
Common Data Source API
erEclipse and Eclipse and NetBeansNetBeans–– DocumentationDocumentation–– SamplesSamples
Arc
GIS
Ser
ve
Arc
IMS
Arc
Web
OG
C\W
MS
Gra
phic
s
Data Sources
ArcGIS Server ArcIMS ArcWeb OGC\WMS
Installed componentsInstalled components
ArcObjects libraries
IDE integration
Multi-source
Single-source (9.1)
Creating Web applicationsCreating Web applications
•• Manager lets you setManager lets you setrequired options required options
ServicesServices–– ServicesServices–– PresentationPresentation–– Tools and TasksTools and Tasks
Eclipse/NetBeans templateEclipse/NetBeans template•• Eclipse/NetBeans template Eclipse/NetBeans template –– Same files as ManagerSame files as Manager
applicationapplicationNavigation Measure andNavigation Measure and–– Navigation, Measure, and Navigation, Measure, and IdentifyIdentify
–– Search AttributesSearch Attributes•• Build using controlsBuild using controls•• Build using controlsBuild using controls
D
Web pagesWeb pages
error.jspDisplays session andall application errorsindex.html
Entry point to theapplication
mapviewer.jspStart pageContains ADF Web controls
application
Configuration filesConfiguration files
•• Contain managed beansContain managed beans
ags-functionalities.xmlData source specific functionalities
context-attributes.xml Set attributes for Web controls
faces-config.xmlData resourceSession attributes andapplication-level variables
web.xmlDeployment descriptor
DemoDemo
•• Investigate installation directoryInvestigate installation directory•• Create web mapping applicationCreate web mapping application
MM–– ManagerManager–– Eclipse TemplateEclipse Template
The Web ADF controlsThe Web ADF controls
•• Set of custom JavaServer Faces Web controlsSet of custom JavaServer Faces Web controls•• Expose server object functionalityExpose server object functionality
M O i T d T lbM O i T d T lb–– Map, Overview, Toc, and ToolbarMap, Overview, Toc, and Toolbar–– Gives access to other APIs (common or resource specific)Gives access to other APIs (common or resource specific)––com.esri.adf.web.faces.componentcom.esri.adf.web.faces.component
•• SDKSDK–– JavaDocJavaDoc–– Web control tag libraryWeb control tag library–– SamplesSamples
What is JSF?What is JSF?
•• ServerServer--side user interface component frameworkside user interface component frameworkfor Web applicationsfor Web applications
Defines stateful UI componentsDefines stateful UI components–– Defines stateful UI componentsDefines stateful UI componentsFor different clients: HTML, WML, etc.For different clients: HTML, WML, etc.
–– Provides event modelProvides event modelLinks client events with server components (backing beans)Links client events with server components (backing beans)Links client events with server components (backing beans)Links client events with server components (backing beans)
–– Includes tools for validation, type conversion, and navigationIncludes tools for validation, type conversion, and navigation–– Aids in rapid application developmentAids in rapid application development
What do the Web ADF controls do?What do the Web ADF controls do?
•• Provide a gateway to resource specific APIsProvide a gateway to resource specific APIs•• Provide an extensible framework Provide an extensible framework
–– Through event model and action listenersThrough event model and action listeners–– Ability to associate multiple renderers (e.g., HTML, WML, DHTML)Ability to associate multiple renderers (e.g., HTML, WML, DHTML)
•• Manage state between HTTP requestsManage state between HTTP requests•• Manage relationships with other JSF componentsManage relationships with other JSF components
The Context controlThe Context control
•• Establishes a connection to the GIS Server (nonEstablishes a connection to the GIS Server (non--visual)visual)•• Container of all attributes and resourcesContainer of all attributes and resources
ContextControl•• Has attributes registered to itHas attributes registered to it–– Notifies attributes about changes Notifies attributes about changes
in application statein application stateW bC t t f hW bC t t f h()()
ContextControl
WebContext––WebContext.refreshWebContext.refresh()()
•• Stored in Stored in requestrequest scopescope–– Data objects can beData objects can be
t i d f t tt i d f t t
ebCo e
retrieved from contextretrieved from context•• Works with a Works with a WebContextWebContext objectobject
WebMap WebTocWebGraphics
mapviewer.jsp
<a:context value="#{mapContext}" />
faces-config.xml
<managed-bean>
<managed-bean-name>mapContext</managed-bean-name>
<managed-bean-class>com.esri.adf.web.data.WebContext</managed-bean-class>. . .
</managed-bean>
The map, overview, and table of contents controlsThe map, overview, and table of contents controlsMap control
•• Map controlMap control–– Map viewMap view–– AJAX enabledAJAX enabled
Map control
–– Works with multiple resourcesWorks with multiple resources
•• Overview controlOverview control<a:map id="map1” value="#{mapContext.webMap}" />
–– Associated with Map controlAssociated with Map control–– Interactive area of interest boxInteractive area of interest box
Overview control
<a:overview mapId="map1” value="#{mapContext.webOverview}" />
•• TOC controlTOC control–– Associated with Map controlAssociated with Map control
Lists map layersLists map layers
TOC control
p p p
–– Lists map layersLists map layers<a:toc mapId="map1” value="#{mapContext.webToc}" />
mapviewer.jsp
DemoDemo
•• JSF controlsJSF controls–– Create JSP page containing map, map overview, and Create JSP page containing map, map overview, and toctoc controlscontrols
The Toolbar controlThe Toolbar control
•• Displays a collection of toolsDisplays a collection of toolsand commands and commands Associated to a Map controlAssociated to a Map control•• Associated to a Map controlAssociated to a Map control
•• Contains a collection of toolbar itemsContains a collection of toolbar items–– ToolTool–– CommandCommand–– DropDrop--down listdown list–– SeparatorSeparator
mapviewer.jsp
<a:toolbar mapId="map1" id="toolbar1"
activeTool="toolZoomIn" >
Commands and toolsCommands and tools
C dC d•• CommandsCommands–– ServerServer--side actions triggered by eventsside actions triggered by events
Example: A user clicks the Full Extent button.Example: A user clicks the Full Extent button.–– No interaction with the map requiredNo interaction with the map required<a:command id="commandFullExtent" toolTip="Full Extent"
defaultImage="images/tasks/maptools/fullext.png“
mapviewer.jsp
•• ToolsTools
selectedImage="images/tasks/maptools/fullextD.png"
actionListener="com.esri.adf.web.faces.event.ZoomFullExtentListener"/>
ToolsTools–– Consist of clientConsist of client--side and serverside and server--side actionsside actions–– Require user interaction with the mapRequire user interaction with the map
Examples: Zoom In Zoom Out etcExamples: Zoom In Zoom Out etc mapviewer jspExamples: Zoom In, Zoom Out, etc.Examples: Zoom In, Zoom Out, etc.<a:tool id="toolZoomOut" clientAction="EsriMapRectangle"
serverAction="com.esri.adf.web.faces.event.ZoomOutToolAction"
defaultImage="images/tasks/maptools/zoomout png"
mapviewer.jsp
defaultImage= images/tasks/maptools/zoomout.png
selectedImage="images/tasks/maptools/zoomoutD.png" toolTip="Zoom Out"/>
DemoDemo
•• Toolbars, tools, and commandsToolbars, tools, and commands–– Add a toolbar to the JSP pageAdd a toolbar to the JSP page
TasksTasks
•• Tasks encapsulate business logicTasks encapsulate business logic•• Tasks can contain parameters, commands, or toolsTasks can contain parameters, commands, or tools•• All tasks have an APIAll tasks have an API
–– Change properties of a task via managed beansChange properties of a task via managed beans
T kTask menu links
ResultsResults panel
ResultDetails
Task UI
CalloutCallout
TaskInfoTaskInfo
•• TaskInfoTaskInfo–– Provides metadata about the taskProvides metadata about the task
Parameter action and tool descriptorsParameter action and tool descriptorsParameter, action, and tool descriptorsParameter, action, and tool descriptorsUsed to define the UI of the taskUsed to define the UI of the task
TaskInfoTask Class<<uses>>
Implementing a taskImplementing a taskAdd the task as a managed bean (Add the task as a managed bean (ff fi lfi l))•• Add the task as a managed bean (Add the task as a managed bean (facesfaces--config.xmlconfig.xml))
–– Set managed properties (optional)Set managed properties (optional)–– Add managed bean to Add managed bean to mapContextmapContext attributes (optional)attributes (optional)
faces-config.xml
<managed-bean>
<managed-bean-name>mapToolsTask</managed-bean-name>
<managed-bean-class>com.esri.adf.web.tasks.MapToolsTask</managed-bean-class>
g
<managed-bean-scope>none</managed-bean-scope>. . .
<managed-property>
<property-name>taskInfo</property-name>
<value>#{mapToolsTaskInfo}</value>
</managed-property>. . .
</managed-bean>
d b T l T kI f / d b<managed-bean-name>mapToolsTaskInfo</managed-bean-name>
<managed-bean-class>com.esri.adf.web.tasks.MapToolsTaskInfo</managed-bean-class>. . .
Implementing a task continuedImplementing a task continued
•• Display the task UIDisplay the task UI–– Tasks menu bar or from a buttonTasks menu bar or from a button
•• Add a task control Add a task control mapviewer.jsp
<a:task id="mapToolsTask" value="#{mapContext.attributes.mapToolsTask}"
taskInfo="#{mapContext.attributes.mapToolsTask.taskInfo}" mapId="map1" />
mapviewer.jsp
DemoDemo
•• Implement Map Tools taskImplement Map Tools task–– Customize available toolsCustomize available tools
Set identifiable layersSet identifiable layers–– Set identifiable layersSet identifiable layers
Tasks included with the ADFTasks included with the ADF
•• Common to all resourcesCommon to all resources––com.esri.adf.web.taskscom.esri.adf.web.tasks
Map Tools taskMap Tools taskMap Tools taskMap Tools taskSearch Attributes taskSearch Attributes taskQuery Attributes taskQuery Attributes taskGeocodeGeocode tasktaskGeocodeGeocode tasktaskPrint taskPrint task
•• ResourceResource--specificspecificcom esri adf web ags data gpcom esri adf web ags data gp––com.esri.adf.web.ags.data.gpcom.esri.adf.web.ags.data.gp
GeoprocessingGeoprocessing tasktask––com.esri.adf.web.ags.taskscom.esri.adf.web.ags.tasks
Editi t kEditi t kEditing taskEditing taskRouting taskRouting task
Task frameworkTask framework
•• Allows custom functionality to be implementedAllows custom functionality to be implemented•• TasksTasks
Obj t th t l t b i l iObj t th t l t b i l i–– 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 toolsUI is implemented for youUI is implemented for you
–– Good way to encapsulate related functionalityGood way to encapsulate related functionality–– Task implementationTask implementation
Similar to implementing a standard JavaBeanSimilar to implementing a standard JavaBean
Implementing a custom taskImplementing a custom task
•• Create a standard Java ClassCreate a standard Java Class–– Signature of method dictatesSignature of method dictates
a command or toola command or toola command or tool a command or tool •• Register the Java class as a managed beanRegister the Java class as a managed bean
in the facesin the faces--configconfigMakes it available in the ADFMakes it available in the ADF–– Makes it available in the ADFMakes it available in the ADF
•• 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–– Visually displays the UI to the userVisually displays the UI to the user
<a href="#"
mapviewer.jsp
onclick="toggleWindow('win_EsriTaskCell_navigationTaskCntrl');">
Navigate</a>
<a:task id="navigationTaskCntrl" value="#{navigationTask}"<a:task id= navigationTaskCntrl value= #{navigationTask}
taskInfo="#{navigationTaskInfo}" mapId="map1"
windowingSupport="true" />
DemoDemo
•• Create custom Navigation taskCreate custom Navigation task–– Create Java ClassCreate Java Class
Register the Java class in facesRegister the Java class in faces configconfig–– Register the Java class in facesRegister the Java class in faces--configconfig–– Add task to JSP pageAdd task to JSP page
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–– 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 mapE l Z t f ll t tE l Z t f ll t t–– 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)
Add parameters to a custom taskAdd parameters to a custom task
•• Parameters Parameters –– Provide inputs for the taskProvide inputs for the task
public class NavigationTask {
double zoomFactor = 0.6;
NavigationTask.java
public double getZoomFactor() {
return zoomFactor;
}
public void setZoomFactor(double zoomFactor) {
this.zoomFactor = zoomFactor;
}
}
Add a selection parameter to a taskAdd a selection parameter to a task
•• DropDrop--down boxdown box
public class NavigationTask {
NavigationTask.java
public class NavigationTask {
. . .
double zoomFactor = 0.6;
. . .
public Map getZoomFactors() {
Map factors = new LinkedHashMap();
for(int i=1; i<=10;i++) {
Double factr = new Double((double)(i*2)/10);
factors.put(factr, factr);
}
return factors;
}
Add a command to a custom taskAdd a command to a custom task
•• Add a method with TaskEventAdd a method with TaskEventas argument as argument
((com esri adf web faces eventcom esri adf web faces event))–– ((com.esri.adf.web.faces.eventcom.esri.adf.web.faces.event))–– Gives accessGives access
to WebContextto WebContextpublic class NavigationTask {
NavigationTask.java
p g {
. . .
public void zoom(TaskEvent event) {
//Get WebContext and WebMap and current extent
WebContext webContext = event.getWebContext();
WebMap webMap = webContext.getWebMap();
WebExtent webExtent = webMap.getCurrentExtent();
//Expand extent, set map to it & refresh context
webExtent expand(zoomFactor);webExtent.expand(zoomFactor);
webMap.setCurrentExtent(webExtent);
webContext.refresh(); } }
DemoDemo
•• Add functionality to custom taskAdd functionality to custom task–– Add parameterAdd parameter
Add commandAdd command–– Add commandAdd command
The task architectureThe task architecture
TaskControlTask Class
Metadata classes ParamDescriptorsMetadata classes(TaskInfo)
ParamDescriptorsActionDescriptorsToolDescriptors
TaskIntrospector
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–– Both clientBoth client--side and serverside and server--side actionsside actions
MapEventMapEvent
Interact with map Task Class
Add method with Add method with MapEventMapEvent as argumentas argumentProvide a Provide a TaskToolDescriptorTaskToolDescriptorS t d b f f T k t lS t d b f f T k t lSet as managed bean, reference from Task controlSet as managed bean, reference from Task control
Add a tool to a custom taskAdd a tool to a custom task
Add method with Add method with MapEventMapEvent as argumentas argumentNavigationTask.java
public class NavigationTask {
public void centerAt(MapEvent event) {
//Get WebContext and WebMap
W bC t t bC t t t tW bC t t()WebContext webContext = event.getWebContext();
WebMap webMap = webContext.getWebMap();
//Get screen geom (in pixels)//Get screen geom (in pixels)
WebGeometry screenGeom = event.getWebGeometry();
//Convert to map coords
WebPoint pnt = (WebPoint)screenGeom.toMapGeometry(webMap);
//Center extent around user click and refresh
webMap.centerAt(pnt, 1.0);
webContext.refresh();
}}
Add a tool to a custom taskAdd a tool to a custom task
Provide a Provide a TaskToolDescriptorTaskToolDescriptor–– ClientClient--side action: Controlled by JavaScript functionsside action: Controlled by JavaScript functions
EsriMapRectangleEsriMapRectangle EsriMapPanEsriMapPan EsriMapPointEsriMapPoint etcetcEsriMapRectangleEsriMapRectangle, , EsriMapPanEsriMapPan, , EsriMapPointEsriMapPoint, etc., etc.ClientActions.MAP_POINTClientActions.MAP_POINT, etc., etc.
–– Extend Extend SimpleTaskInfoSimpleTaskInfo
public class NavigationTaskInfo extends SimpleTaskInfo {
p blic TaskToolDescriptorModel[] getToolDescriptors() {
NavigationTaskInfo.java
public TaskToolDescriptorModel[] getToolDescriptors() {
return new TaskToolDescriptor[] {
new TaskToolDescriptor(NavigationTask.class, “centerAt",
“Center At",“EsriMapPoint”)
};
}
}
Add a tool to a custom taskAdd a tool to a custom task
Set as managed bean, reference from Task controlSet as managed bean, reference from Task controlfaces-config.xml
<managed-bean>
<managed-bean-name>navigationTaskInfo</managed-bean-name>
<managed-bean-class>com.exercise06.NavigationTaskInfo</managed-bean-class>
< d b > </ d b ><managed-bean-scope>none</managed-bean-scope>
</managed-bean>
<a:task id="navigationTask" value="#{navigationTask}"
taskInfo="#{navigationTaskInfo}" mapId="map1" windowingSupport="true" />
Mapviewer.jsp
DemoDemo
•• Add more functionality to custom taskAdd more functionality to custom task–– Add toolAdd tool
CreateCreate TaskToolDescriptorTaskToolDescriptor–– Create Create TaskToolDescriptorTaskToolDescriptor
Demo Developer APIsDemo Developer APIs
•• Geometry Service via SOAPGeometry Service via SOAP•• Graphics LayerGraphics Layer
QQ•• QueryQuery•• Web ResultsWeb Results
ArcGISArcGIS Resource CentersResource CentersDeveloper Help Developer Help
•• Developer SDK’sDeveloper SDK’s•• Sample GIS ServerSample GIS Server
G SG S OO•• ArcGISArcGIS OnlineOnline•• Online HelpOnline Help•• CommunityCommunity
–– Blogs & ForumsBlogs & Forums–– Code GalleryCode Gallery
•• SupportSupportpppp–– Knowledge BaseKnowledge Base–– Software updatesSoftware updates
http://resources.esri.comhttp://resources.esri.com
More learningMore learning
•• Sessions:Sessions:–– Building Great Web Maps Using Building Great Web Maps Using ArcGISArcGIS
Today at 4:00 PM room 204CToday at 4:00 PM room 204CToday at 4:00 PM, room 204CToday at 4:00 PM, room 204C–– Developing Applications with Developing Applications with ArcGISArcGIS Server and the Microsoft .NET Server and the Microsoft .NET
FrameworkFrameworkToday at 4:00 PM, room 207BToday at 4:00 PM, room 207BToday at 4:00 PM, room 207BToday at 4:00 PM, room 207B
–– BuldingBulding MashupsMashups Using the Java Script API and FLEX for Using the Java Script API and FLEX for ArcGISArcGIS ServerServerTomorrow at 10:30 AM, room 207BTomorrow at 10:30 AM, room 207B
•• Instructor Led Training at ESRIInstructor Led Training at ESRI–– Introduction to Introduction to ArcGISArcGIS ServerServer–– Introduction to ProgrammingIntroduction to Programming ArcObjectsArcObjects Using the Java PlatformUsing the Java PlatformIntroduction to Programming Introduction to Programming ArcObjectsArcObjects Using the Java PlatformUsing the Java Platform–– Developing Applications with Developing Applications with ArcGISArcGIS Server Using the Java PlatformServer Using the Java Platform–– Courses in .NET are also availableCourses in .NET are also available