Configuring Web controls


In this topic


Sample application Web controls

Several Web controls are used in the Simple ArcGIS Server Web ADF application (the "sample application"). Some of them are visible, such as map and tool Web controls, and others are invisible, such as the context control. Before these controls can be used, they must be configured in your Web Application Developer Framework (ADF) application.
Configuring Web controls involves the following Extensible Markup Language (XML) files:
  • context-attributes.xml
  • ags-functionalities.xml
  • faces-config.xml

context-attributes.xml

In context-attributes.xml, a managed bean called map is created, which is the logic representation of the map Web control in the sample application. After the managed bean is created, you need to set attributes for it. One example of a map managed bean attribute is setting imageFormat to Portable Network Graphics (PNG).
The following code example is in context-attributes.xml of the sample application.
[XML]
<managed-bean>
  <managed-bean-name>map</managed-bean-name>
  <managed-bean-class>com.esri.adf.web.data.WebMap</managed-bean-class>
  <managed-bean-scope>none</managed-bean-scope>
  <managed-property>
    <property-name>imageFormat</property-name>
    <value>PNG</value>
  </managed-property>
</managed-bean>
The sample application has only a map control, so only a map control managed bean needs to be created. If you want to add more controls, such as table of contents (TOC) or overview controls, you can create managed beans for them and put them in context-attributes.xml.

ags-functionalities.xml

In ags-functionalities.xml, several managed beans are created for different functionalities in the ArcGIS Server map resource of ArcIMS (which are created in faces-config.xml). The sample application uses the following managed beans:
  • agsMap—A managed bean representing map functionality for the map control.
  • agsToc—A managed bean representing table of content functionality for the table control.
  • agsOverview—A managed bean representing overview functionality for the overview control.
The following code example is in ags-functionalities.xml of the sample application.
[XML]
<managed-bean>
  <managed-bean-name>agsMap</managed-bean-name>
  <managed-bean-class>com.esri.adf.web.ags.data.AGSMapFunctionality</managed-bean-class>
  <managed-bean-scope>none</managed-bean-scope>
</managed-bean>
<managed-bean>
  <managed-bean-name>agsToc</managed-bean-name>
  <managed-bean-class>com.esri.adf.web.ags.data.AGSTocFunctionality</managed-bean-class>
  <managed-bean-scope>none</managed-bean-scope>
</managed-bean>
<managed-bean>
  <managed-bean-name>agsOverview</managed-bean-name>
  <managed-bean-class>com.esri.adf.web.ags.data.AGSOverviewFunctionality</managed-bean-class>
  <managed-bean-scope>none</managed-bean-scope>
</managed-bean>
Once a functionality managed bean is created and added as a map resource managed bean attribute, that functionality is available in the Web ADF application. In the sample application, only the map functionality is added as an attribute of map resource. Additional functionality, such as query, geocode, and history, can be created and added if necessary.

faces-config.xml

The following four managed beans are created in faces-config.xml.
  • ags1
  • esriWebApplication
  • esriWebSession
  • mapContext
The ags1 managed bean represents the geographic information system (GIS) data resource you want to publish in the Web application. In the sample application, it will be an ArcGIS Server or ArcIMS GIS service. The functionality managed beans (defined in ags-functionalities.xml) are added as attributes of this map resource managed bean.
The esriWebApplication managed bean is always set to application scope in a Web ADF application.
The esriWebSession managed bean holds the esriWebApplication managed bean as an attribute.
The mapContext managed bean is the logic representation for context control and also holds the esriWebSession managed bean and the map managed bean as its attributes. These three managed beans are necessary for any Web ADF application, especially the mapContext managed bean, which connects and coordinates all other components in a Web ADF application. That's also the reason why you use the map managed bean as its attribute and ags1 as its resource.
The following code example is in faces-config.xml of the sample application.
[XML]
<managed-bean>
  <managed-bean-name>esriWebApplication</managed-bean-name>
  <managed-bean-class>com.esri.adf.web.data.WebApplication</managed-bean-class>
  <managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean>
  <managed-bean-name>esriWebSession</managed-bean-name>
  <managed-bean-class>com.esri.adf.web.data.WebSession</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
  <managed-property>
    <property-name>webApplication</property-name>
    <value>#{esriWebApplication}</value>
  </managed-property>
</managed-bean>
<managed-bean>
  <managed-bean-name>mapContext</managed-bean-name>
  <managed-bean-class>com.esri.adf.web.data.WebContext</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
  <managed-property>
    <property-name>webSession</property-name>
    <value>#{esriWebSession}</value>
  </managed-property>
  <managed-property>
    <property-name>attributes</property-name>
    <map-entries>
      <map-entry>
        <key>map</key>
        <value>#{map}</value>
      </map-entry>
    </map-entries>
  </managed-property>
  <managed-property>
    <property-name>resources</property-name>
    <map-entries>
      <map-entry>
        <key>ags1</key>
        <value>#{ags1}</value>
      </map-entry>
    </map-entries>
  </managed-property>
</managed-bean>
<managed-bean>
  <managed-bean-name>ags1</managed-bean-name>
  <managed-bean-class>com.esri.adf.web.ags.data.AGSMapResource</managed-bean-class>
  <managed-bean-scope>none</managed-bean-scope>
  <managed-property>
    <property-name>user</property-name>
    <value>#{agsUser1}</value>
  </managed-property>
  <managed-property>
    <property-name>serverObjectName</property-name>
    <value>usa</value>
  </managed-property>
  <managed-property>
    <property-name>hosts</property-name>
    <list-entries>
      <value>YourServer</value>
    </list-entries>
  </managed-property>
  <managed-property>
    <property-name>functionalities</property-name>
    <map-entries>
      <map-entry>
        <key>map</key>
        <value>#{agsMap}</value>
      </map-entry>
      <map-entry>
        <key>overview</key>
        <value>#{agsOverview}</value>
      </map-entry>
    </map-entries>
  </managed-property>
</managed-bean>
Once these managed beans are properly configured in context-attribute.xml, ags-functionalities.xml, and faces-config.xml, you can add them as Web control JavaServer Faces (JSF) tags to the JavaServer Pages (JSP) of your Web ADF application.


See Also:

Writing a JSP page
How to add a command or tool
Creating a multisource Web ADF application