|
Comments
|
Today's Top SOA Links
Feature AjaxWorld Special: Creating AJAX and Rich Internet Components with JSF
AJAX has gained momentum primarily due to the "XMLHttpRequest" browser object which supports asynchronous communication
By: Jonas Jacobi; John Fallows
Apr. 6, 2006 09:30 AM
This article is based on, and contains excerpts from, the book Pro JSF: Building Rich Internet Components by Jonas Jacobi and John Fallows, published by Apress. Book is now available on fine bookstores and Amazon as of February 25, 2006.
Consumer Requirements Introduction to Rich Internet Technologies From a combination of both consumer requirements and developer needs, a new breed of Web technologies has evolved. Often referred to as Rich Internet Technologies, these technologies enhance the traditionally static content provided by Web applications. In the absence of sufficiently powerful standards, new technologies such as Mozilla's XUL, Microsoft's HTC, Java applets, Flex, and OpenLaszlo have emerged to meet the requirements. Such technologies support application-specific extensions to traditional HTML markup while still leveraging the benefits of deploying an application to a central HTTP server. XMLHTTP has also returned under a newly branded name, AJAX (Asynchronous JavaScript and XML). Applications built with these technologies are often referred to as Rich Internet Applications (RIA). In this article series we are going to focus on AJAX and XUL to illustrate the potential that JSF brings to the JavaEE developer. AJAX With the XMLHttpRequest object, developers can now send requests to the Web server to retrieve only the data needed and use JavaScript to process the response.This ability to reduce the amount of data transferred between client and Web server reduces the bandwidth to a minimum and saves processing time on the server since most of the processing is done on the client using JavaScript. It is important to note that the XMLHttpRequest object, although widely used, could at best be called a "de facto" standard, since most browsers, including Firefox, Inter-net Explorer, Opera, and Safari, support it. It is also worth noting that the XMLHttpRequest object is not exclusive to AJAX; potentially the XMLHttpRequest object can be used by any HTML/XML-based Web technology such as XUL or HTC. Desktop vs Web A typical AJAX application leverages standard HTML/XHTML at the presentation layer and uses JavaScript to dynamically change the DOM. This creates an effect of "richness" in the user interface with no dependency on additional browser plug-ins. Mozilla XUL XUL Structure XUL Components XUL uses a language called XBL (eXtensible Binding Language) to define new components. XBL is also used to bridge the gap between XUL and HTML, making it easy to attach behavior to traditional HTML markup. Listing 1 is a sample XUL file that embeds XUL elements and standard, name-spaced HTML elements. XUL Event Handling As in HTML, developers can use JavaScript functions located in external libraries, or embedded in the page. <script type="text/javascript"src="http:// There is a large set of built-in XUL components, each with its own set of event handler attributes. For example, the XUL window element delivers events such as load and paint. Creating Custom XUL Components Using XBL Developers can look at XUL as the "implementation" that comes with a pre-set of components, or tag libraries that can be used to build a user interface, much like the JSF Reference Implementation. XBL is the language developers use to extend XUL components and enable integration with HTML, in much the same way that Java is used to extend JSF components. XBL Structure A quick look at Listing 3 shows the root <bindings> element containing two binding elements. A <bindings> element can contain any number of <binding> elements. The namespace in the <bindings> element defines which syntax will be used, and in Listing 3 it is XBL - xmlns=http://www.mozilla.org/xbl. The file also contains a combination of XUL and HTML elements <xul:text/> and <html:input/>. This is extremely useful for simplifying development by encapsulating several components as a single, reusable component. The xbl:inherits attribute allows the text element to inherit values from the bound element by defining a variable called name and assigns it to the value attribute. If no value is defined when the component is used in a page, the text field's value will default to "Guest". Reader Feedback: Page 1 of 1
Your Feedback
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||||||||