com.esri.adf.web.data
Interface WebContextInitialize

All Known Implementing Classes:
AGSExtensionsResource, AGSGeocodeResource, AGSGeometryResource, AGSGPResource, AGSImageResource, AGSLocalExtensionsResource, AGSLocalGeocodeResource, AGSLocalGeometryResource, AGSLocalGPResource, AGSLocalImageResource, AGSLocalMapResource, AGSMapResource, AIMSMapResource, DefaultGraphicsResource, EditBean, ExtentHistory, GeocodeTask, GISResource, GPJobResultsTask, GraphicsResource, MapToolsTask, PrintTask, QueryAttributesTask, RoutingTask, SearchAttributesTask, VEGeocodeResource, VEImageryResource, VEResource, WebContext, WebGeocode, WebGraphics, WebMap, WebNorthArrow, WebOverview, WebQuery, WebResultsToc, WebScaleBar, WebToc, WMSMapResource

public interface WebContextInitialize

The WebContextInitialize interface is implemented by attributes of the WebContext to initialize and cleanup themselves at appropriate junctures of the ADF lifecycle. This interface defines callback methods which are called when the attribute is initialized and destroyed.

Attributes are considered ready for use only after init(WebContext) has been called on them and they are considered unusable after destroy() has been called on them.

It's a good practice for classes to maintain a reference to the WebContext that is passed to them by the init(WebContext) method as an instance variable.

 public class MyAttribute implements WebContextInitialize {
   WebContext context;
 
   public void init(WebContext context) {
     this.context = context;
     //perform other initialization chores
   }
 
   public void destroy() {
     context = null;
     //perform cleanup chores such as releasing held resources
   }
 }
 

Attributes can be registered either programmatically (context.setAttribute("myAttr", new MyAttribute());) or in JSF managed bean configuration files as such:

 <managed-bean>
   <managed-bean-name>myAttr</managed-bean-name>
   <managed-bean-class>myPackage.MyAttribute</managed-bean-class>
   <managed-bean-scope>none</managed-bean-scope>
 </managed-bean>
  
 <managed-bean>
   <managed-bean-name>myContext</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>attributes</property-name>
     ...
     <map-entries>
       <map-entry>
         <key>myAttr</key>
         <value>#{myAttr}</value>
       </map-entry>
     </map-entries>
   </managed-property>
 </managed-bean>
 


Method Summary
 void destroy()
           The cleaup chores (such as releasing held resources) of attributes of a WebContext should be performed in this method.
 void init(WebContext context)
           The initialization chores of attributes of a WebContext should be performed in this method.
 

Method Detail

init

void init(WebContext context)

The initialization chores of attributes of a WebContext should be performed in this method.

Typically this method is called by the WebContext when the context itself is initialized. It is important to note that this method is again called by the context when a GISResource is dynamically added to or removed from the context. Classes that implement this method should keep this in mind and adapt the method to react to the callbacks in these circumstances as well.

A WebContext attribute is usable only after this method has been called.

Parameters:
context - WebContext- the WebContext
See Also:
WebContext.init(WebContext), WebContext.addResource(String, GISResource, int), WebContext.removeResource(GISResource)

destroy

void destroy()

The cleaup chores (such as releasing held resources) of attributes of a WebContext should be performed in this method.

Typically this method is called by the WebContext when the context itself is destroyed.

The WebContext attribute is unusable after this method has been called.

See Also:
WebContext.destroy()