Hi,

A.  My best guess (and it is a guess) is that your onBeforeInit is not
firing because the listener registration is happening in the 'init'
processing, which is _after_ onBeforeInit would have fired.  I'd be
intererested to know why it has to be 'before' and not 'after'.  My sense
is that you should avoid 'before' unless there is some reason you can't use
'after'.

B.  I strongly suggest that you look into using ND-supplied adapters and
anonymous inner classes.  With this approach, you only have to define
methods that actually do something for you, and you have more flexibility,
in that you can support two or more completely different listeners even if
they share method signatures, which you can't do (at least not easily) if
the class directly implements the listeners.

Here's a suggestion based on your sample code.  I'm assuming that you
really want to put in code for onBeforeInitEvent, onBeforeDisplayEvent, and
onBeforeHtmlOutputEvent, and not for onAfterInitEvent.

-- Curt Springer, Team ND (see below)

package Inherit;

import spider.database.*;
import spider.visual.*;
import spider.*; 
import java.awt.event.*;
import java.util.*;
import spider.event.*;

//this added:
import spider.event.adapters.*;

import spider.session.*;
import spider.html.*;
import spider.util.*;

//[[SPIDER_CLASS BEGIN
public class MyPage extends spider.visual.CSpPage
//page no longer implements listener interfaces
{

        /**
        * Constructor 
        */
        public MyPage()
        {
                super();
        }
        
        
        /**
        * Initialize object and register listeners. 
        */
        public int init()
        {
                super.init();
                addInitListener(
                new CSpFileBasedEventAdapter()
                        {

                                //**************
                                //* as noted above, this probably won't work for the 
same reason that
it doesn't work in the original version

//**************************************************************************
******************************************************

                                public int onBeforeInitEvent(CSpInitEvent event)
                                        {
                                        CSpLog.send(this, CSpLog.CRITICAL, 
"*****Entering OnBeforeInit
Event*****"); 

                                        return (PROCEED);
                                        }//public int onBeforeInitEvent(CSpInitEvent 
event)


                        }//new CSpFileBasedEventAdapter()

                );


                addDisplayListener(
                new ISpDisplayListener()
                        {
                                public int onBeforeDisplayEvent(CSpDisplayEvent event)
                                        {
                                                return (PROCEED);
                                        }//public int 
onBeforeDisplayEvent(CSpDisplayEvent event)

                        }//new ISpDisplayListener()


                        );


                addHtmlOutputListener(
                        new ISpHtmlOutputListener()
                                {
                                public int onBeforeHtmlOutputEvent(CSpHtmlOutputEvent 
event)
                                        {
                                                CSpLog.send(this, CSpLog.CRITICAL,  
"*****Entering My Event*****"); 
                                                return (PROCEED);
                                        }//public int 
onBeforeHtmlOutputEvent(CSpHtmlOutputEvent   event)


                                }//new ISpHtmlOutputListener()


                        );
                
                return (PROCEED);
        }//public int init()
        
}//public class MyPage extends spider.visual.CSpPage


At 10:58 AM 5/7/99 -0800, [EMAIL PROTECTED] wrote:
>Does anyone understand why the onBeforeInitEvent() would not fire
>when the listener has been implemented?
>
>When implementing ISpInitListener, one must implement both the 
>onBeforeInitEvent() and onAfterinitEvent().  For me, the 
>onAfterInit event fires, but not the onBeforeInitEvent().
>Unfortunately, my code needs to go in the OnBeforeInitEvent() and not the
OnAfterInitEvent.
>
>Some sample code follows:
>
>
>package Inherit;
>
>import java.awt.event.*;
>import java.util.*;
>import spider.event.*;
>import spider.database.*;
>import spider.visual.*;
>import spider.*; 
>import spider.session.*;
>import spider.html.*;
>import spider.util.*;
>
> 
>//[[SPIDER_CLASS BEGIN
>public class MyPage extends spider.visual.CSpPage
>implements spider.event.ISpInitListener,
>spider.event.ISpDisplayListener,
>spider.event.ISpHtmlOutputListener
>{
>
>       /**
>       * Constructor 
>       */
>       public MyPage()
>       {
>               super();
>       }
>       
>       
>       /**
>       * Initialize object and register listeners. 
>       */
>       public int init()
>       {
>               super.init();
>               addInitListener(this);
>               addDisplayListener(this);
>               addHtmlOutputListener(this);
>               
>               return (PROCEED);
>       }
>       
>
>       public int onBeforeDisplayEvent(CSpDisplayEvent event)
>       {
>               return (PROCEED);
>       }
>       
>
>       public int onBeforeHtmlOutputEvent(CSpHtmlOutputEvent   event)
>       {
>       CSpLog.send(this, CSpLog.CRITICAL,  "*****Entering My Event*****"); 
>               return (PROCEED);
>       }
>
>       
>       public int onBeforeInitEvent(CSpInitEvent event)
>       {
>               CSpLog.send(this, CSpLog.CRITICAL, "*****Entering OnBeforeInit
Event*****"); 
>               return (PROCEED);
>       }
>
>
>       public int onAfterInitEvent(CSpInitEvent event)
>       {
>                               return (PROCEED);
>       }
>
>
>}
>
>_________________________________________________________________________
>
>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