Archive for November, 2007

720 Part III . Document Objects Reference Listing (Web server hosting)

Sunday, November 25th, 2007

720 Part III . Document Objects Reference Listing 29-3 (continued)

 layer1

In some cases, your scripts need to know if an event that is passed onward by routeEvent() method activated a function that returns a value. This knowledge is especially valuable if your event must return a trueor falsevalue to let an object know if it should proceed with its default behavior (for example, whether a link should activate its HREF attribute URL or cancel after the event handler evaluates to return true or return false). When a function is invoked by the action of a routeEvent() method, the return value of the destination function is passed back to the routeEvent()method. That value, in turn, can be returned to the object that originally captured the event. Event traffic cop The last scenario is one in which a higher-level object captures an event and directs the event to a particular object elsewhere in the hierarchy. For example, you could have a document-level event handler function direct every click event whose modifiers property indicates that the Alt key was pressed to a Help button object whose own onClick event handler displays a help panel (perhaps shows an otherwise hidden layer). You can redirect an event to any object via the handleEvent() method. This method works differently from the others described in this chapter, because the object reference of this method is the reference of the object to handle the event
Check Tomcat Web Hosting services for best quality webspace to host your web application.

719Chapter 29 .Event Objects } else (Web file server) { document.releaseEvents(Event.CLICK)

Saturday, November 24th, 2007

719Chapter 29 .Event Objects } else { document.releaseEvents(Event.CLICK) document.forms[0].setDocRte.checked = false docRoute = false } } function setLayerCapture(enable) { if (!enable) { document.layer1.captureEvents(Event.CLICK) } else { document.layer1.releaseEvents(Event.CLICK) document.forms[0].setLyrRte.checked = false layerRoute = false } } var docRoute = false var layerRoute = false function setDocRoute(enable) { docRoute = !enable } function setLayerRoute(enable) { layerRoute = !enable } function doMainClick(e) { if (e.target.type == button ) { alert( Captured in top document ) if (docRoute) { routeEvent(e) } } } document.captureEvents(Event.CLICK) document.onclick=doMainClick Capture, Release, and Routing of Event.CLICK


Enable Document Capture  And let event continue

Enable Layer Capture  And let event continue


Continued
You want to have a cheap webhost for your apache application, then check apache web hosting services.

718 Part (Web server application) III . Document Objects Reference Listing

Saturday, November 24th, 2007

718 Part III . Document Objects Reference Listing 29-2 (continued) NAME= layerButton2 onClick= alert( Event finally reached Button: + this.name) >

Passing events toward their targets If you capture a particular event type, your script may need to perform some limited processing on that event before letting it reach its intended target. For example, perhaps you want to do something special if a user clicks an element with the Shift metakey pressed. In that case, the function that handles the event at the document level inspects the event s modifiers property to determine if the Shift key was pressed at the time of the event. If the Shift key was not pressed, you want the event to continue on its way to the element that the user clicked. To let an event pass through the object hierarchy to its target, you use the routeEvent() method, passing as a parameter the event object being handled in the current function. A routeEvent() method does not guarantee that the event will reach its intended destination, because another object in between may have event capturing for that event type turned on and will intercept the event. That object, too, can let the event pass through with its own routeEvent()method. Listing 29-3 demonstrates event routing by adding onto the document being built in previous examples. While the clickable button objects are the same, additional powers are added to the document and layer function handlers that process events that come their way. For each of these event-capturing objects, you have additional checkbox settings to allow or disallow events from passing through after each level has processed them. The default settings for the checkboxes are like the ones in Listing 29-2, where event capture (for the click event) is set for both the document and layer objects. Clicking any button causes the document object s event handler to process and none other. But if you then enable the checkbox that lets the event continue, you find that click events on the layer buttons cause alerts to display from both the document and layer object event handler functions. If you then also let events continue from the layer object, a click on the button displays a third alert, showing that the event has reached the buttons. Because the main1 button is not in the layer, none of the layer object event handling settings affect its behavior. Listing 29-3: NN4 Capture, Release, and Route Events Document-level and/or Layer-level capture of Event.CLICK
Enable Document Capture Enable Layer Capture
 layer1

Check Tomcat Web Hosting services for best quality webspace to host your web application.

Ecommerce web host - 716 Part III . Document Objects Reference Listing

Friday, November 23rd, 2007

716 Part III . Document Objects Reference Listing 29-1 (continued)


With document-level event capture turned on (the default), all click events are trapped by the document s onclickevent handler property, a function that alerts the user that the event was captured by the top document. Because all click events for buttons are trapped there, even click events of the layer s buttons are trapped at the top. But if you turn off event capture, the events reach their intended targets. Note If the logic of the setDocCapture() function seems backwards to you, recall that when the onMouseDown event fires on the checkbox, its state is the opposite of what it is being changed to. In Listing 29-2, I add some code (shown in boldface) that lets the layer object capture clickevents whenever the outer document event capture is turned off. Inside the tag, a script sets the layer to capture clickevents. Therefore, if you disable the outer document capture, the clickevent goes straight to the main1 button and to the layer event capture. Event capture in the layer object prevents the events from ever reaching the buttons in the layer, unless you disable event capture for both the document and the layer. Listing 29-2: Document and Layer Event Capture and Release Basic document-level capture of Event.CLICK
Enable Document Capture
Continued
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Web server setup - 714 Part III . Document Objects Reference NN4

Thursday, November 22nd, 2007

714 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
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

713Chapter 29 .Event Objects object (Web design tools) and all its

Thursday, November 22nd, 2007

713Chapter 29 .Event Objects object and all its properties are still alive and available to your scripts. But after the last script statement runs, the event object reverts to an empty object. The reason an event object has such a brief life is that there can be only one event object at a time. In other words, no matter how complex your event handler functions are, they are executed serially (for experienced programmers: there is one execution thread). The operating system buffers events that start to bunch up on each other. Except in rare cases in which the buffer gets full and events are not recorded, event handlers are executed in the order in which the events occur. The static Event object Up to this point, the discussion has been about the event object (with a lower case e ), which is one instance of an event, with all the properties associated with that specific event action. In the NN4 and W3C DOM event models, there is also a static Event object (with an uppercase E ). In the W3C DOM event model are addi tional subcategories of the Event object. These subcategories are all covered later in this chapter, but they are introduced here to draw the contrast between the event and Event objects. The former, as you ve seen, is a transient object with details about a specific event action; the latter serves primarily as a holder of event-related constant values that scripts can use. The static Event object is always available to scripts inside any window or frame. If you want to see a list of all Event object properties in NN4 and NN6+, use The Evaluator (Chapter 13): enter Event into the bottom text box (also check out the KeyEvent object in NN6+). The static Event object also turns out to be the object from which event objects are cloned. Thus, the static Event object has a number of properties and methods that apply to (are inherited by) the event objects created by event actions. These relationships are more important in the W3C DOM event model, which builds upon the DOM s object-oriented tendencies to implement the event model. Event Propagation Prior to the Version 4 browsers, an event fired on an object. If an event handler was defined for that event and that object, the handler executed; if there was no event handler, the event just disappeared into the ether. Newer browsers, however, send events on a longer ride, causing them to propagate through the document object models. As you know by now, three propagation models exist, one for each of the event models in use today: NN4, IE4+, and W3C DOM as implemented in NN6+. Conceptually, the NN4 and IE4+ propagation models are diametrically oppo site each other. But the W3C DOM model manages to implement both models simul taneously, albeit with all new syntax so as not to step on the older models. At the root of all three models is the notion that every event has a target. For user-initiated actions, this is fairly obvious. If you click a button or type in a text box, that button is the target of your mouse-related event; the text box is the target of your keyboard event. System-generated events are not so obvious, such as the onLoad event after a page finishes loading. In all event models, this event fires on the window object. What distinguishes the event propagation models is how an event reaches its target, and what, if anything, happens to the event after it finishes executing the event handler associated with the target.
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

712 Part III . Document Objects Reference Why (Web design software)

Wednesday, November 21st, 2007

712 Part III . Document Objects Reference Why Events ? Graphical user interfaces are more difficult to program than the old-fashioned command-line interface. With a command-line or menu-driven system, users were intentionally restricted in the types of actions they could take at any given moment. The world was very modal, primarily as a convenience to programmers who led users through rigid program structures. That all changed in a graphical user interface, such as Windows, MacOS, X Window System, and all others derived from the pioneering work of the Xerox Star system. The challenge for programmers is that a good user interface in this realm must make it possible for users to perform all kinds of actions at any given moment: roll the mouse, click a button, type a key, select text, choose a pull-down menu item, and so on. To accommodate this, a program (or, better yet, the operating system) must be on the lookout for any possible activity coming from all input ports, whether it be the mouse, keyboard, or network connection. A common methodology to accomplish this at the operating system level is to look for any kind of event, whether it comes from user action or some machine-generated activity. The operating system or program then looks up how it should process each kind of event. Such events, however, must have some smarts about them so that the program knows what and where on the screen the event is. What an event knows (and when it knows it) Although the way to reference an event object varies a bit among the three event models, the one concept they all share is that an event object is created the instant the event action occurs. For instance, if you click a button, an event object is created in the browser s memory. As the object is created, the browser assigns values to its properties properties that reflect numerous characteristics of that specific event. For a click event, that information includes the coordinates of the click and which mouse button was used to generate the event. To be even more helpful, the browser does some quick calculations to determine that the coordinates of the click event coincide with the rectangular space of a button element on the screen. Therefore, the event object has as one of its properties a reference to the screen thing that you clicked on. Most event object properties (all of them in some event models) are read-only, because an event object is like a snapshot of an event action. If the event model were to allow modification of event properties, performing both potentially useful and potentially unfriendly actions would be possible. For example, how frustrating would it be to a user to attempt to type into a text box only to have a keystroke modified between the actual key press and then have a totally different character appear in the text box? On the other hand, perhaps it may be useful in some situations to make sure that anything typed into a text box is converted to uppercase characters, no matter what is typed. Each event model brings its own philosophy to the table in this regard. For example, the IE4+ event model allows keyboard character events to be modified by script; the NN4 and W3C DOM event models do not. Perhaps the most important aspect of an event object to keep in mind is that it exists only as long as scripts process the event. An event can trigger an event handler usually a function. That function, of course, can invoke other functions. As long as statements are still executing in response to the event handler, the event
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

Event Objects (Web hosting bandwidth) Prior to NN4 and IE4, user

Wednesday, November 21st, 2007

Event Objects Prior to NN4 and IE4, user and system actions events were captured predominantly by event handlers defined as attributes inside HTML tags. For instance, when a user clicked a button, the clickevent triggered the onClick event handler in the tag. That handler may invoke a separate function or perform some inline JavaScript script. Even so, the events themselves were rather dumb: Either an event occurred or it didn t. Where an event occurred (that is, the screen coordinates of the pointer at the moment the mouse button was clicked) and other pertinent event tidbits (for example, whether a keyboard modifier key was pressed at the same time) were not part of the equation. Until the Version 4 browsers, that is. While remaining fully backward-compatible with the event handler mechanism of old, Version 4 browsers had the first event model that turned events into first-class objects whose properties automatically carry a lot of relevant information about the event when it occurs. These properties are fully exposed to scripts, allowing pages to respond more intelligently about what the user does with the page and its elements. Another new aspect of Version 4 event models was the notion of event propagation. It was possible to have an event processed by an object higher up the element containment hierarchy whenever it made sense to have multiple objects share one event handler. That the event being processed carried along with it information about the intended target, plus other golden information nuggets, made it possible for event handler functions to be smart about processing the event without requiring an event handler call to pass all kinds of target-specific information. Unfortunately, the joy of this newly found power is tempered by the forces of object model incompatibility. No fewer than three event object models are in use today: The one initiated by NN4 (whose importance diminishes with each passing day as users migrate to other, newer browsers); the IE4+ model; and the model adopted by the W3C DOM Level 2 as implemented in NN6+. Many of these distinctions are addressed in the overviews of the object models in Chapter 15. In this chapter, you find out more about the actual event objects that contain all the goodies. Where possible, cross- browser concerns are addressed. 29 CHAPTER …. In This Chapter The life of an event object Event support in different browser generations Retrieving information from an event ….
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.