|
| Introduction / Overview | Discussion Forum |
| IMF Developer's Guide » Application Startup Description |
General Application Startup Process
To understand the configuration discussion, you should be aware of the ways that the site can be initialized, and what is actually going on behind the scenes when it starts.
The IMF application can be called several ways from a web browser. Examples of the different methods appear below:
http://imfhost.com/imf/imf.jsp http://imfhost.com/imf/imf.jsp?service=MyMap http://imfhost.com/imf/imf.jsp?server=MyServer&service=MyMap http://imfhost.com/imf/imf.jsp?config=http://MyServer/config.xml http://imfhost.com/imf/imf.jsp?service=MyMap&extent=1000,1000,20000,30000 http://imfhost.com/imf/imf.jsp?server=MyServer&service=MyMap&extent=10000,10000,20000,30000 http://imfhost.com/imf/imf.jsp?config=http://MyServer/config.xml&extent=10000,10000,20000,30000 http://imfhost.com/imf/imf.jsp?site=aquifers http://imfhost.com/imf/imf.jsp?site=aquifers&extent=10000,10000,20000,30000
Note that the URL used in the example is for a production instance of the IMF installation at Moxi Media. The URL used to start the IMF application will be different in other organizations.
The first example results in the default site, the second and third example results in the default site with a different map, and the other examples result in a fully configured site. The command line can also contain an extent argument to specify the initial extent of the map. This document is mainly concerned with the fully configured method, because that is the way to configure a custom site using the Internet Mapping Framework.
The important point here is that the application can be instructed to display maps and documents that are being served on other servers, while using the core application processes served by the IMF server. This facilitates rapid application deployment as it eliminates the need for site developers to program the difficult mapping routines.
On the IMF server in the config directory, there is a site configuration XML file called site-config.xml. This file contains settings for map server, map service, document content, tabs and map tools for the default mapping web site for an organization.
The first thing that the application does when it is called is read the contents of the site configuration XML file even if the IMF URL contains a config or site parameter. This file contains information about the map server, frame documents, tabs and tools. It also contains settings that point at the location of the layer configuration file (if applicable). The layer file is not read at this point, but the URL is saved.
So, now the application has all the information needed to create a web site. Next, the application parameters are read.
If there are no parameters, the default layer configuration file is read and applied, and the default site is displayed.
If there is a map service parameter, the default layer configuration file is ignored (it probably doesn't apply anyway), and the default site is displayed with the alternate map service.
If there is a config parameter, the XML file is accessed and read. Settings from the second file
are used to overwrite the ones already read from the default site-config.xml file. All settings are
optional in the second file, as the default setting will be used if there is not a matching tag in
the second file. It is important to note that if you want to define your own tabs or tools, you
will have to define them all. If you include a
Note that the layer configuration URL read in the first file is cleared, but the second file can (should usually) contain settings for the URL of the layer configuration XML used for the custom site.
If the site is a known site with a value in the site.properties file on the IMF server, the site can be called with the site=sitename argument instead of pointing it to an XML document in the command line. For example, if you have a site named basemap that has its site configuration file at http://slkapps2.env.gov.bc.ca/basemap/site-config.xml, and you would prefer not to have the location of the XML file required in the URL, you can put the following in your site.properties file, then access your site like http://imfhost.com/imf/imf.jsp?site=basemap.
# site.properties # # Specifies the location of site configuration files for known # applications so that the application can be called using # http://imf-host/imf/imf.jsp?site=sitename # # format: site_name = url to site configuration file basemap = http://imfhost.com/basemap/site-config.xml
If there is an extent parameter, the initial extent of the map will be the specified extent.
Startup Queries
IMF can be started with a query. A startup query can be used to select and zoom to features in a layer using query parameters added to the call to imf.jsp. The parameters are:
imf.jsp?site=test&qlyr=Streams&qry=SDE.STREAMS.CODE=123&qhlt=true&qzoom=true imf.jsp?site=test&qlyr=Streams&qry=SDE.STREAMS.CODE=123&qsel=true
Arbitrary Parameters
If you develop your own scripts within IMF that require information to be passed to IMF when it starts, note that you can call IMF with arbitrary parameters. These parameters are 'remembered' by IMF and available for you to access in your scripts. For example, you may wish to call IMF with a property ID from another application like follows:
http://imfhost.com/imf/imf.jsp?site=property&pid=23456... then have a routine in your application that does something specific to the property.
When called this way, IMF stores the value of the arbitrary parameter that was added to the imf.jsp request as a property of the AimsWebSiteConfig object associated with the user's session. For the example above, retrieve the value as in your script as follows:
AimsWebSiteConfig conf = (AimsWebSiteConfig) session.getAttribute("siteConfig");
String pid = conf.getProperty("pid");
This capability is extremely useful when used with startup scripts, described next.
Startup Scripts
If you want IMF to do something special on startup, you can execute one or more JSP scripts after IMF has been initialized but before the frames are set up. For example, you may wish to open IMF with a 5 KM buffer acetate polygon shown around the property. To do this, call IMF with the property id in an arbitrary parameter as detailed above, and create a startup script that will create the buffer, zoom the map, etc. using the property id passed to IMF. To let IMF know that you want a startup script to execute, simply put a <startup-script> element in your site's site configuration XML file. For example, if your script is called pidBuffer.jsp and is in the ext directory, add this to your site configuration file:
<startup-script file="ext/pidBuffer.jsp"/>Note that you can have more than one startup script. If so, they will be executed in the order that they appear in the site configuration file. A global startup script defined in the default site configuration file will be executed for all sites before any site-specific startup scripts.