714 Part III . Document Objects Reference NN4 (Java web server)
Monday, November 26th, 2007714 Part III . Document Objects Reference NN4 event propagation Although the installed base of NN4 continues to diminish, its propagation model initiated some concepts that are found in the modern W3C DOM event propagation model. The name for the model is event capture. In NN4, all events propagate from the top of the document object hierarchy (starting with the windowobject) downward to the target object. For example, if you click a button in a form, the click event passes through the windowand document (and, if available, layer) objects before reaching the button (the form object is not part of the propagation path). This propagation happens instantaneously, so that there is no performance penalty by this extra journey. The event that passes through the window, document, and layer objects is a fully formed event object, complete with all properties relevant to that event action. Therefore, if the event were processed at the window level, one of the event object s properties is a reference to the target object, so that the event handler scripts at the window level can find out information, such as the name of the button and even get a reference to its enclosing form. By default, event capture is turned off. To instruct the window, document, or layer object levels to process that passing click object requires turning on event capture for the window, document, and/or layer object. Enabling NN4 event capture All three objects just mentioned window, document, and layer have a captureEvents() method. You use this method to enable event capture at any of those object levels. The method requires one or more parameters, which are the event types (as supplied by Event object constants) that the object should capture, while letting all others pass untouched. For example, if you want the window object to capture all keyPress events, you include the following statement in a script that executes as the page loads: window.captureEvents(Event.KEYPRESS) Defining event handlers in the intended targets is also a good idea, even if they are empty (for example, onKeyPress= ) to help NN4 generate the event in the first place. If you want the window to capture multiple event types, string the event type constants together, separated by the pipe character: window.captureEvents(Event.KEYPRESS | Event.CLICK) Now you must assign an action to the event at the window s level for each event type. More than likely, you have defined functions to execute for the event. Assign a function reference to the event handler by setting the handler property of the window object: window.onKeyPress = processKeyEvent window.onClick = processClickEvent Hereafter, if a user clicks a button or types into a field inside that window, the events are processed by their respective window-level event handler functions. Turning off event capture As soon as you enable event capture for a particular event type in a document, that capture remains in effect until the page unloads or you specifically disable the capture. You can turn off event capture for each event via the window, document, or layer releaseEvents() method. The releaseEvents() method takes the same
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.