{
}
public void startExamplePanel()
{
final ItsNatDocument itsNatDoc = getItsNatDocument();
Document doc = itsNatDoc.getDocument();
this.linkToStart = doc.getElementById("linkToStartId");
this.globalListener = new EventListener()
{
public void handleEvent(Event evt)
{
if (!(evt instanceof ItsNatDOMStdEvent)) return;
ItsNatDOMStdEvent itsNatEvt = ((ItsNatDOMStdEvent)evt);
String num = (String)itsNatEvt.getExtraParam("num");
if (num == null) return; // Any other
log("Enter in global listener");
ItsNatEventListenerChain chain = itsNatEvt.getItsNatEventListenerChain();
try
{
if (num.equals("1")||num.equals("2"))
chain.continueChain();
else
chain.stop(); // Avoids third listener
}
catch(Exception ex)
{
log("Catched exception thrown by first listener");
}
finally
{
log("Exit from global listener");
}
}
};
itsNatDoc.addEventListener(globalListener);
listeners[0] = new EventListener() // First listener
{
public void handleEvent(Event evt)
{
throw new RuntimeException("Must be catched by global");
}
};
itsNatDoc.addEventListener((EventTarget)linkToStart,"click",listeners[0],false,new CustomParamTransport("num","1"));
listeners[1] = new EventListener() // Second listener
{
public void handleEvent(Event evt)
{
log("Second listener executed");
}
};
itsNatDoc.addEventListener((EventTarget)linkToStart,"click",listeners[1],false,new CustomParamTransport("num","2"));
listeners[2] = new EventListener() // Third listener
{
public void handleEvent(Event evt)
{
throw new RuntimeException("NEVER THROWN!");
}
};
itsNatDoc.addEventListener((EventTarget)linkToStart,"click",listeners[2],false,new CustomParamTransport("num","3"));
}