There have been many forum questions about the correct usage of the context control in a multiple page web application. I will be the first one to admit that this is more of a bug in the ADF than an incorrect usage on the part of the user. Ok, so the short end of it is this question: How do I access the same context across multiple pages of an ADF web application?
Typically, the context is specified on a JSP using the context
tag:
<ags:context id="myCtx" resource="myServerObject@myHost"/>
Now, in an ideal world, if you have multiple pages in your webapp, you should have to use the context control in the exact same manner on all other pages and it should work fine. Unfortunately, that's not the case at 9.1. Currently, the way the
context
tag works is that if you specify the
resource
attribute of the tag, the first time that the page is accessed, it actually creates a
new context. What this means is that if you use the
context
tag by specifying the
resource
attribute on different pages of the same webapp, it gives an impression that the context is "resetting" itself - i.e. the current state of your application is lost and the application reverts to the original state of the map server object.
A workaround to this problem is that on subsequent pages of your webapp, you should not specify the
resource
attribute of the
context
tag and ensure that the
id
is same as the id that you specified on the main page:
<ags:context id="myCtx"/>
<!-- resource attribute is not used and id is same as the id of the context on the main page -->
If the
resource
attribute is not specified, the
context
tag does not create a new context but instead tries to find an existing context with the same id as specified in the
id
attribute. So as long as you have the correct id specified, the context that you created on the main page will be accessed on all subsequent pages of the webapp.
This is admittedly confusing and we have addressed it at 9.2 so that the context control can be used in a consistent manner across all pages of the webapp.