com.esri.arcgis.webcontrols.data
Class WebContext

java.lang.Object
  extended bycom.esri.arcgis.webcontrols.data.WebContext
All Implemented Interfaces:
Serializable, WebLifecycle
Direct Known Subclasses:
AGSWebContext

public abstract class WebContext
extends Object
implements WebLifecycle

The abstract WebContext class works with the ContextControl to provide access to the data objects. The WebContext acts as a container for the WebMap, WebPageLayout, WebOverview, WebGeocode and the WebToc. The WebContext is stored in session and all objects within its scope are accessible as a request attribute. Custom attributes defined by the user can also be stored on the WebContext.

See Also:
Serialized Form

Field Summary
protected  Hashtable attributes
          The custom objects stored within the WebContext as request attributes.
protected  WebGeocode geocode
          The WebGeocode in this context.
protected  int id
          The unique id for this context.
protected  WebMap map
          The WebMap in this context.
protected  WebOverview overview
          The WebOverview in this context.
protected  WebPageLayout pageLayout
          The WebPageLayout in this context.
static String REQUEST_ATTRIBUTE_NAME
          Deprecated. No longer required. The WebContext is stored in session using a unique ID.
protected  String resource
          The resource string.
protected  String resourceType
          The type of the resource.
protected  WebSession session
          The WebSession which maintains this context.
protected  WebToc toc
          The WebToc in this context.
 
Constructor Summary
WebContext()
           
 
Method Summary
 void activate()
          Activates the WebContext.
 void addObserver(WebContextObserver observer)
          Adds an observer to the WebContext.
 void destroy()
          Destroys the WebContext.
 Object getAttribute(String name)
          Returns the custom object stored in the attribute name.
 Map getAttributes()
          Returns the attributes of the Map associated with this WebContext.
 int getId()
          Returns the unique identifier for this context.
 String getResource()
          Returns the resource string.
 String getResourceType()
          Returns the resource type.
 WebGeocode getWebGeocode()
          Returns the WebGeocode for this context.
 WebGeocode getWebGeocode(boolean create)
          Returns the WebGeocode object for this context.
 WebMap getWebMap()
          Returns the WebMap associated with this context.
 WebMap getWebMap(boolean create)
          Returns the WebMap associated with this context.
 WebOverview getWebOverview()
          Returns the WebOverview for this context.
 WebOverview getWebOverview(boolean create)
          Returns the WebOverview associated with this context.
 WebPageLayout getWebPageLayout()
          Returns the WebPageLayout associated with this context.
 WebPageLayout getWebPageLayout(boolean create)
          Returns the WebPageLayout associated with this context.
 WebSession getWebSession()
          Returns the current WebSession for this context.
 WebToc getWebToc()
          Returns the WebToc for this context.
 WebToc getWebToc(boolean create)
          Returns the WebToc associated with this context.
protected abstract  void init(String resource, String resourceType, String dataFrame)
          An abstract initialization method which must be implemented by the concrete sub-class to initialize the context.
 void init(String resource, String resourceType, String dataFrame, int id, WebSession session)
          Initializes the WebContext.
 void passivate()
          Passivates the WebContext.
 void refresh()
          Refreshes the WebContext by calling the refresh method with a null refresh argument.
 void refresh(Object arg)
          Refreshes the WebContext by specifying a refresh ID.
 void setAttribute(String name, Object value)
          Sets a custom object as an attribute of the WebContext.
 void setWebGeocode(WebGeocode geocode)
          Sets the WebGeocode for this context.
 void setWebMap(WebMap map)
          Sets the WebMap for this context.
 void setWebOverview(WebOverview overview)
          Sets the WebOverview for this context.
 void setWebPageLayout(WebPageLayout pageLayout)
          Sets the WebPageLayout for this context.
 void setWebToc(WebToc toc)
          Sets the WebToc for this context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_ATTRIBUTE_NAME

public static final String REQUEST_ATTRIBUTE_NAME
Deprecated. No longer required. The WebContext is stored in session using a unique ID.

The name by which a WebContext can be referenced in a request.

See Also:
Constant Field Values

id

protected int id
The unique id for this context.


attributes

protected Hashtable attributes
The custom objects stored within the WebContext as request attributes.


resource

protected String resource
The resource string.


resourceType

protected String resourceType
The type of the resource.


session

protected WebSession session
The WebSession which maintains this context.


map

protected WebMap map
The WebMap in this context.


pageLayout

protected WebPageLayout pageLayout
The WebPageLayout in this context.


toc

protected WebToc toc
The WebToc in this context.


overview

protected WebOverview overview
The WebOverview in this context.


geocode

protected WebGeocode geocode
The WebGeocode in this context.

Constructor Detail

WebContext

public WebContext()
Method Detail

init

public final void init(String resource,
                       String resourceType,
                       String dataFrame,
                       int id,
                       WebSession session)
                throws Exception
Initializes the WebContext. Generic properties are initialized and init method of the concrete sub-class (for example, AGSWebContext) is called to perform further initialization.

Parameters:
resource - the resource
resourceType - the type of resource
dataFrame - the default data frame. This is specific to GIS server.
id - the id of the context
session - the WebSession
Throws:
Exception - if the arguments are invalid

getResource

public String getResource()
Returns the resource string.

Returns:
String- the resource string

getResourceType

public String getResourceType()
Returns the resource type.

Returns:
String- the resource type

init

protected abstract void init(String resource,
                             String resourceType,
                             String dataFrame)
                      throws Exception
An abstract initialization method which must be implemented by the concrete sub-class to initialize the context.

Parameters:
resource - the resource string
resourceType - the type of resource
dataFrame - the default data frame. This is specific to GIS server.
Throws:
Exception - if initialization fails

getWebSession

public WebSession getWebSession()
Returns the current WebSession for this context.

Returns:
WebSession- the WebSession

getId

public int getId()
Returns the unique identifier for this context.

Returns:
int- the unique id

setWebMap

public void setWebMap(WebMap map)
Sets the WebMap for this context.

Parameters:
map - the WebMap

getWebMap

public WebMap getWebMap(boolean create)
Returns the WebMap associated with this context. The implementing class can implement this method if it wants to create a new WebMap object based on the create argument. The default implementation calls getWebMap().

Parameters:
create - if true, create the WebMap
Returns:
WebMap- the WebMap

getWebMap

public final WebMap getWebMap()
Returns the WebMap associated with this context.

Returns:
WebMap- the WebMap

setWebPageLayout

public void setWebPageLayout(WebPageLayout pageLayout)
Sets the WebPageLayout for this context.

Parameters:
pageLayout - the WebPageLayout

getWebPageLayout

public WebPageLayout getWebPageLayout(boolean create)
Returns the WebPageLayout associated with this context. The implementing class can implement this method if it wants to create a new WebPageLayout object based on the create argument.

Parameters:
create - if true, create the WebPageLayout
Returns:
WebPageLayout- the WebPageLayout

getWebPageLayout

public final WebPageLayout getWebPageLayout()
Returns the WebPageLayout associated with this context.

Returns:
WebPageLayout- the WebPageLayout

setWebToc

public void setWebToc(WebToc toc)
Sets the WebToc for this context.

Parameters:
toc - the WebToc

getWebToc

public WebToc getWebToc(boolean create)
Returns the WebToc associated with this context. The implementing class can implement this method if it wants to create a new WebToc object based on the create argument.

Parameters:
create - if true, create the WebToc
Returns:
WebToc- the WebToc

getWebToc

public final WebToc getWebToc()
Returns the WebToc for this context.

Returns:
WebToc- the WebToc object

setWebOverview

public void setWebOverview(WebOverview overview)
Sets the WebOverview for this context.

Parameters:
overview - the WebOverview

getWebOverview

public WebOverview getWebOverview(boolean create)
Returns the WebOverview associated with this context. The implementing class can implement this method if it wants to create a new WebOverview object based on the create argument.

Parameters:
create - if true, create the WebOverview
Returns:
WebOverview- the WebOverview

getWebOverview

public final WebOverview getWebOverview()
Returns the WebOverview for this context.

Returns:
WebOverview- the WebOverview

setWebGeocode

public void setWebGeocode(WebGeocode geocode)
Sets the WebGeocode for this context.

Parameters:
geocode - the WebGeocode

getWebGeocode

public WebGeocode getWebGeocode(boolean create)
Returns the WebGeocode object for this context. The implementing class can implement this method if it wants to create a new WebGeocode object based on the create argument.

Parameters:
create - if true, create the WebGeocode object
Returns:
WebGeocode- the WebGeocode

getWebGeocode

public final WebGeocode getWebGeocode()
Returns the WebGeocode for this context.

Returns:
WebGeocode- the WebGeocode

setAttribute

public void setAttribute(String name,
                         Object value)
Sets a custom object as an attribute of the WebContext.

Parameters:
name - the attribute name
value - the value of the attribute

getAttribute

public Object getAttribute(String name)
Returns the custom object stored in the attribute name.

Parameters:
name - the attribute name
Returns:
Object- the custom object

getAttributes

public Map getAttributes()
Returns the attributes of the Map associated with this WebContext.

Returns:
Map- a Map of attributes stored on the WebContext

addObserver

public final void addObserver(WebContextObserver observer)
Adds an observer to the WebContext. All registered observers of the WebContext are guaranteed to have their update method called on refresh.

Parameters:
observer - the WebContextObserver

refresh

public final void refresh()
Refreshes the WebContext by calling the refresh method with a null refresh argument.


refresh

public final void refresh(Object arg)
Refreshes the WebContext by specifying a refresh ID. The update methods of all registered observers of the WebContext are invoked.

Parameters:
arg - the refresh arguments (for example, AGSRefreshID.MAP_OPERATION)

destroy

public void destroy()
Destroys the WebContext. For all attributes on the context that implement WebLifecycle, the destroy method is called.

Specified by:
destroy in interface WebLifecycle

activate

public void activate()
Activates the WebContext. For all attributes on the context that implement WebLifecycle, the activate method is called.

Specified by:
activate in interface WebLifecycle

passivate

public void passivate()
Passivates the WebContext. For all attributes on the context that implement WebLifecycle, the passivate method is called.

Specified by:
passivate in interface WebLifecycle