EventTarget currTarget = evt.getCurrentTarget();
if (currTarget == linkElem)
{
ItsNatEvent itsNatEvt = (ItsNatEvent)evt;
final ItsNatDocument itsNatDoc = itsNatEvt.getItsNatDocument();
final ClientDocument clientDoc = itsNatDoc.getClientDocumentOwner();
Runnable dispCode = new Runnable()
{
public void run()
{
for(int i = 0; i < buttonElems.length; i++)
{
Element buttonElem;
MouseEvent mouseEvt;
synchronized(itsNatDoc)
{
Document doc = itsNatDoc.getDocument();
AbstractView view = ((DocumentView)doc).getDefaultView();
mouseEvt = (MouseEvent)itsNatDoc.createEvent("MouseEvents");
mouseEvt.initMouseEvent("click",true,true,view,0,
0,0,0,0,false,false,false,false,(short)0/*left button*/,null);
buttonElem = buttonElems[i];
}
((EventTarget)buttonElem).dispatchEvent(mouseEvt);
// Alternatives:
// itsNatDoc.dispatchEvent((EventTarget)buttonElem,mouseEvt);
// clientDoc.dispatchEvent((EventTarget)buttonElem,mouseEvt);
}
ItsNatUserEvent userEvt;
synchronized(itsNatDoc)
{
userEvt = (ItsNatUserEvent)itsNatDoc.createEvent("itsnat:UserEvents");
userEvt.initEvent("itsnat:user:myEvent",false,false);
}
((EventTarget)userButton).dispatchEvent(userEvt);
}
};
clientDoc.startEventDispatcherThread(dispCode);
}
else
{
System.out.println("Clicked: " + ((Element)currTarget).getAttribute("value"));
}