example of invoking listener as anonymous inner class
//*****************************************************************
/**
* initialize the state of the object.
*
* @returns int - Return code that indicates what should
* be done next
* @see spider.CSpFileBased#PROCEED
* @see spider.CSpFileBased#SKIP
* @see spider.CSpFileBased#STOP
* @see
*/
//*****************************************************************
public int init()
{
// initialize the object
super.init();
_outer = this;
// allow object to listen for onBeforeHtmlOutputEvent events
addHtmlOutputListener(
new ISpHtmlOutputListener() {
//*****************************************************************
/**
* Event handler for event that occurs right before HTML is output
* to the HTTP buffer. HTML has been generated at this point, but
* not necessarily in the format of what is needed. Get final
HTML
* from the HMSHtmlObject for this field.
*
* @param event Event source
* @return int Return code that defines the next
operation
* @see edu.harvard.hms.hmsapi.visual.HMSHtmlObject
* @see spider.visual.CSpVisual
* @see spider.CSpFileBased#PROCEED
* @see spider.CSpFileBased#SKIP
* @see spider.CSpFileBased#STOP
* @see
spider.event.ISpHtmlOutputListener#onBeforeHtmlOutputEvent
* @see spider.visual.CSpVisual#addHtmlOutputListener
* @see spider.event.CSpHtmlOutputEvent
*/
//*****************************************************************
public int onBeforeHtmlOutputEvent(CSpHtmlOutputEvent event)
throws CSpStopException
{
try
{
// set the final HTML for this field to that defined
// by the HMSHtmlObject for this field.
setHtmlText (_hmshtmlobject.getHtmlText(_updateresults));
// Proceed with processing for this object
return (PROCEED);
} // try
catch( Exception ex )
{
writeLog(_outer, "onBeforeHtmlOutputEvent, unexpected
Exception: "+ex);
// an exception has occurred.
// Stop processing for this object
throw (new CSpStopException());
} // catch ( Exception ex)
}//public int onBeforeHtmlOutputEvent(CSpHtmlOutputEvent event)
}//new ISpHtmlOutputListener(){
);//addHtmlOutputListener(
return (PROCEED);
} //public int init()
Troy,
You need to add a listener that implements the onBeforeDisplayEvent method.
We do this stuff with anonymous inner classes. Don't have time to look
stuff up now.
-- Curt, Team ND
At 12:58 PM 6/30/99 -0400, Troy Mckinnon wrote:
>Hey all,
>
>I have a question regarding event overriding:
>
>I am trying to add some functionality to the onBeforeDisplayEvent of a
>button.
>
>
>Fin code below:
>
>public class testButton extends CSpButton
>
>{
> public int init()
> {
> enableEvents (CSpEvent.DISPLAY_EVENT_MASK);
> return super.init();
> }
>
> protected void processDisplayEvent(CSpDisplayEvent event) throws
>CSpSkipException , CSpStopException
> {
> int command=PROCEED;
>
> if (event.getId () == CSpDisplayEvent.ON_BEFORE_DISPLAY_EVENT ) {
>// I would rather do this with the setVisible(false) method but it won't
>work here.
> if(dontShowMe)
> throw new CSpSkipException ();
>}
> super.processDisplayEvent(event);
> }
>
>// Why can't I add actions to the event by including it here in the
>superclass??
>// This event does not register at all.
> public int onBeforeDisplayEvent(CSpDisplayEvent event)
> throws CSpSkipException , CSpStopException {
> CSpHtml.sendMessage("<br>---onBeforeDisplayEvent-----");
> Object src = event.getSource();
> return myMethod((CSpButton)src);
> }
>
>
> protected int myMethod(CSpButton bt) throws CSpSkipException
> if(doIt)
> {
> CSpHtml.sendMessage("<br>Security Event<br>");
> throw new CSpSkipException();
> }
> return PROCEED;
> }
>
>
>}
>
>
>
>--------------------
>
>I would really appreciate any comments or advice...
>
>
>Thanks
>
>Troy
>
>Troy McKinnon
>Technical Team Leader
>Integrated Quality Management System
>Nortel Networks - GHCT (Dept. 1J11)
>(613) 765-7685 or ESN (395) 7685
>
>_________________________________________________________________________
>
>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]