74 CHAPTER 3 CONTENT CHUNKING PATTERN In (Web hosting providers)
74 CHAPTER 3 CONTENT CHUNKING PATTERN In this example, the variable img is an instance of an Image, which cross-references to the HTML tag img. The property src is assigned the URL of the image. The last line of the code chunk uses the method appendChild to add the instantiated Image instance to the HTML docu ment. Not associating the variable img with the HTML document will result in an image that is loaded but not added to the HTML document, and hence not generated. The resulting gener ated HTML page is shown in Figure 3-12. E B V N Figure 3-12. Generated HTML page after image has been inserted Figure 3-12 is not that spectacular because it illustrates yet again how an image can be added to an HTML page. What is of interest is that the text Nothing has remained and is not replaced as in previous examples. The reason is that the method appendChild was used (and not replaceChild or removeChild, and then appendChild). The advantage of using the Dynamic HTML object model approach is that it enables images or arbitrary actions to be downloaded in the background that can at the script s choosing be displayed. Instantiating Objects Another type of JavaScript chunk that can be downloaded are object states. By using an object state, you can add a level of indirection, allowing functionality to be added during the execution of the HTML page. In all of the past example HTML code pieces, the initial HTML page had to have all the scripts and know the URLs of the resources that were retrieved. Using an indirection, the JavaScript on the client side does not need to know the specifics of a URL or data structure. The client references a general piece of code that is executed. The general piece of code is managed by the server, and contains specific instructions to do something that the client was not programmed to do. Using indirection, it is possible to add functionality to the client that the client did not possess at design time.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.