Re: DOM Events

Stewart:

Here an example of an application defining an event, where canDispatch 
returns 'false'  (at least in our interpretation of the current 
specification)

[it's java :-)]
-----------------------------------------
DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
Document document = docBF.newDocumentBuilder().newDocument();

if (document.getImplementation().hasFeature("Events", "2.0")) {
  DocumentEvent docEvent = (DocumentEvent)document.getFeature("+Events", 
"2.0");
  EventListener el = new EventListener(){public void handleEvent(Event 
evt){}};

  CustomEvent event = (CustomEvent)docEvent.createEvent("CustomEvent");
  event.initCustomEventNS(null, "myType", true, true, "myCustomEvent");
      
  ((EventTarget)document).addEventListenerNS(event.getNamespaceURI(), 
event.getType(), el, false, null);
  ((EventTarget)document).dispatchEvent(event);
          
  if(!docEvent.canDispatch(event.getNamespaceURI(), event.getType())) {
    /* here: canDispatch()=false ... do we really want this being 
false?!?! */
    System.out.println("DocumentEvent.canDispatch(...) returns false.");
  }
}
-----------------------------------------
the point/confusion being here that this method returns false for all 
events with namespaceURI that doesn't equal null. It happens for 
CustomEvents with namespaceURI that equals null also. But all such 
events should be generated and dispatched correctly. Again (our feeling) 
is that the specification sounds like the implementation 
cannot/should-not dispatch application specific events.



-- 
Jean-Yves Bitterlich, Sun Microsystems GmbH, Sonnenallee 1, 85551 
Heimstetten, Germany


Amtsgericht München: HRB 161028

Geschäftsführer: Marcel Schneider, Wolfgang Engels, Dr. Roland Bömer

Vorsitzender des Aufsichtsrates: Martin Häring

WEEE-Reg.-Nr. DE 20803943

HypoVereinsbank München, Konto 31 625 009, BLZ 700 202 70

Received on Wednesday, 11 April 2007 08:12:23 UTC