I'm still dumbfounded as to why ND doesn't re-initialize all page
session objects on a page (and removing those that are not initially
placed on the page in the studio) before giving them to the worker
thread.  Only reason I can think of is performance, but that is a
poor reason considering the problems this can cause.  Without this
capability, one has to code defensively when using page session objects.
At the least, it would be handy to be able to configure the system
to spit an warning if a web event tries to read from a page session
object that was not written to (or initialized) in that same web event.

Here's a chunk of code we use in the onBeforeProjectFreeEvent of
our common page class.  It works under the following assumptions,
(1) All of our page session objects start with "ksePag" (2) all
of our page session objects are strings.  This isn't an example
of "correct" code (subjectively, whatever that means), but so far
it seems to work for us in ND5.

   // Wipe out all of our page session objects.  If we don't they seem
   // to get set to odd values here an there.
   //
   // Note: Removing our objects has really bad side-effects, that's
   //       why just wipe them out instead.
   Hashtable objects = getPageSession().getHashTable().getHashTable();
   Enumeration keys = objects.keys();
   while (keys.hasMoreElements())
   {
      String key = (String)keys.nextElement();
      if (key.startsWith("ksePag"))
      {
         putPageSessionObject((String)key, new CSpString(""));
      }
      else
      {
         // FIX: Is it okay to remove ND page session variables?  I have
         //      noticed no ill side-effects from this yet.
         removePageSessionObject((String)key);
      }
   }

Be well,
Ryan

Johann Ludwig wrote:
> 
> "LadyNaureen" <[EMAIL PROTECTED]> wrote:
> >
> >Dear ND Experts
> >
> >Hello to All,
> >
> >The problem scenario is I have a variable that is used by all functions in a page.
         For the  first time the project starts nicely, moving initializing value in 
this
         variable. But if I rerun my application then the  old value of the variable 
is retrieved,
         so my application goes down. Anyone knows why this is happening????
> >Thanks in advance.
> >
> >Regards,
> >LadyNaureen
> >
> 
> I have noticed too that page variables seem to keep their values, even if the user
         session is out. The only way I found is to re-initialize variables , e.g. at 
yourPage_onBeforeDataObjectExecuteEvent.
> If you find a much better way, please tell me.
> 
> Johann Ludwig ([EMAIL PROTECTED])
_________________________________________________________________________

For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html

For dire need help, email: [EMAIL PROTECTED]

Reply via email to