Actually, I didn't suggest that you do the mapping in
this_onBeforeDisplayEvent.  I was suggesting not doing mapping at all.

Now that I look at it, there was this line:
>>getEventAdapter (), false);

that I meant to delete, it was noise from when I copied the code from
somewhere else.  Sorry if that made it confusing.

Maybe I misunderstood, but I thought your intent was in fact to do the same
thing for every object on the page.  That was one reason I questioned your
use of event mapping.


-- Curt

At 07:13 PM 5/27/99 +0530, Krupesha C wrote:
>Event Mapping should be done in onAfterInitEvent() only.
>I tried to implement event mapping in this_onBeforeDisplayEvent() as
>suggested by you. Problem is that, the mapped function is called for every
>visual object and object gets populated (when this_onBeforeDisplayEvent() is
>happening). But the object's properties  set here will be overridden by the
>default properties set in studio. Might be, ND tries to populate the visual
>objects after this_onBeforeDisplay().
>The code works fine for onBeforeHtmlOutputEvent() also, provided
>"CSpHtmlOutputEvent" is passed, not "CSpDisplayEvent"
>
>Regards,
>Krupesha
>
>
>-----Original Message-----
>From: Curt Springer [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, May 25, 1999 10:04 PM
>To: [EMAIL PROTECTED]
>Subject: Re: [ND] Event Mapping in onAfterInitEvent() not working
>
>
>Hi,
>I'm not sure if event mapping is ideal for anything, actually.
>
>It was ND's response to people like me yelling that they broke our code
>going from ND3->ND4.  And it does work, but it's complicated to set up, not
>intuitive, imho, and easily breakable (as in your case with using private
>instead of public on the method).
>
>Since I did stuff using this approach, I have been working together on a
>project with Grace Frederick, the ND world expert on display field
>superclasses, and also I have been doing things with listeners and
>anonymous inner classes.  I'm not at the point of saying that there is no
>situation where I would use event mapping in the future, but I'm almost
>there, maybe will make that determination when pressure is off and we have
>a chance to assess some stuff we've rushed up lately.
>
>Perhaps I'll say a little more on this topic in the next day or so.  Don't
>have time right now.
>
>-- Curt Springer, Team ND
>
>
>At 07:51 PM 5/25/99 +0530, Krupesha C wrote:
>>Thanks Curt,
>>The code is working fine for "onBeforeDisplayEvent", once I made the method
>>public. But still it was not working for "onBeforeHtmlEvent". I made the
>>code to work with the help of your second suggestion. Thanks !
>>And also, what is the ideal situation in which event mapping function could
>>be used?
>>
>>Regards,
>>Krupesha
>>
>>
>>
>>-----Original Message-----
>>From: Curt Springer [mailto:[EMAIL PROTECTED]]
>>Sent: Tuesday, May 25, 1999 6:26 PM
>>To: [EMAIL PROTECTED]
>>Cc: [EMAIL PROTECTED]
>>Subject: Re: [ND] Event Mapping in onAfterInitEvent() not working
>>
>>
>>I've done a fair amount of this stuff.  It's a little bit tricky.
>>
>>One thing that jumps out is that your method 'myMappingFunction' is
>>private.  It must be public.  I don't have time to do a detailed review of
>>your code versus mine to see what else there might be.
>>
>>I also wonder if you really need to use the event mapping function, seeing
>>that you're applying it to all page children.
>>
>>Here's another possible way to do it:
>>
>>public int this_onBeforeDisplayEvent(WhateverEvent event)
>>{

>>      for (int i = 0; i < numOfChildren; i++)
>>              CSpVisual v = (CSpVisual)_children.elementAt (i);
>>              populatePlease(v);
>>getEventAdapter (), false);
>>      }
>>
>>
>>}
>>
>>A couple of cautions:
>>
>>-- The hidden page session object is one of the page children.  You
>>probably want to exclude this from your routine field processing.   You can
>>test on 'instanceof CSpPageSessionHidden' (look up the exact class name)
>>
>>-- I hadn't realized that the parent-level class variable _children is
>>protected.  You could insulate yourself from changes to ND's future
>>structure by calling getChildren and then cycling through the returned list
>>(which can be converted to an Enumeration)
>>
>>-- Curt Springer, Team ND
>>
>>
>>At 05:10 PM 5/25/99 +0530, Krupesha C wrote:
>>>The ND documentation says that, you can map the events associated with
>>>visual objects to user defined methods in onAfterInitEvent(). This will be
>>>helpful when the same code is used by many visual objects for
>>>initialization. Instead of calling the user defined function in
>>>visulaObject_onBeforeDisplayEvent(), we can map this method to event's
>>>onBefore...Event() using CSpVisual.mapEvent() method
>>>
>>>Even though usage looks perfect for me, am getting the following error (ND
>>>4.1):
>>>spider.event.adapters.CSpPageEventAdapter.addEventMapping: Can't find the
>>>method 'myMappingFunction' in target Object
>>>of type 'myProject.myPage'
>>>
>>>The code used is like this:
>>>
>>>public int this_onAfterInitEvent(CSpInitEvent event)
>>>{
>>>     int numOfChildren = _children.size ();  //list of visuals
>>>     for (int i = 0; i < numOfChildren; i++)
>>>
>>>
>>>             CSpVisual v = (CSpVisual)_children.elementAt (i);
>>>             v.mapEvent ("onBeforeDisplayEvent", this, "myMappingFunction",
>>>getEventAdapter (), false);
>>>     }
>>>     return (PROCEED);
>>>}
>>>
>>>
>>>private int myMappingFunction(CSpDisplayEvent event)
>>>{
>>>     populatePlease((CSpVisual) event.getSource());  //Call generic routine now
>>>}
>
>>>
>>>(ND Documention Series reference: "Changes You Have to Make to Your Code"
>>>under "Migrating NetDynamics Projects to 4.x." of "Technical Briefs".
>>>.../NetDynamics/NetDynamics40/Docs/res/techbriefs/migrate.html#@Changes)
>>>
>>>
>>>Thanks for your time,
>>>Krupesha
>>>
>>>
>>>
>>>
>>_________________________________________________________________________
>>
>>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]
>>
>_________________________________________________________________________
>
>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]
> 
_________________________________________________________________________

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