Welcome!

Machine Learning Authors: Liz McMillan, Pat Romanski, Elizabeth White, Yeshim Deniz, Jason Bloomberg

Related Topics: Machine Learning , Java IoT

Machine Learning : Article

The Benefits Of The AJAX RenderKit

ADF Faces has now been donated to the open source community

In an effort to provide developers with a productive environment, Oracle has been working on a very rich UI component framework for several years. This framework - ADF Faces - has now been donated to the open source community. More precisely, it has been donated to the Apache Software Foundation and is currently hosted in the Apache Incubator - http://incubator.apache.org/projects/adffaces.html. Craig McClanahan is mentoring the project during the Apache incubation. The Apache MyFaces community is also involved in the project to assist with graduation from the incubator, into the Apache MyFaces "ADF Faces" subproject.

What is ADF Faces? ADF Faces is a comprehensive, free JSF component library. This library contains 12 helper objects such as converters and validators, and 93 components ranging from simple input components to complete page components with built-in menu model support. In addition, ADF Faces provides a set of extended services such as a dialog framework and a skinning framework.

In a series of articles we will be deep diving into various aspects of this donation and give developers insight into its internal functionality and how to use and extend ADF Faces. In this first article we discuss the HTML AJAX RenderKit provided by this JSF component library.

The ADF Faces HTML AJAX RenderKit
As most of you probably know by now, AJAX is a new phenomenon, but the technologies that make up AJAX are not. AJAX, for those who don't know, is a technique that uses native browser technologies to provide highly interactive user interfaces and to asynchronously communicate with server-side logic.

Since the technologies backing AJAX have been around for quite some time, there have been AJAX solutions available long before the term was coined. One of those is the ADF Faces "AJAX" RenderKit. This solution has been called partial page rendering (PPR) and has been used by Oracle and its customers for several years. Instead of re-rendering the entire page on a postback, PPR will only update a portion of the page.

With AJAX, or PPR, application developers can then provide a rich and interactive, desktop-like user interface on the Web.

Practical Benefits of ADF Faces AJAX RenderKit
To fully appreciate the benefits that the ADF Faces AJAX RenderKit provides, we first need to look at some of the common problems end users are facing with a traditional Web application.

Problems with Full Page Refresh
End users normally spend time waiting for a server response without being able to do anything else, and, if they do, it might actually cause problems, like double-submit. The scroll position and focus in the page are usually lost even when the same page is redisplayed after a user interaction such as expanding a tree node. Validation is usually delayed until the user explicitly presses submit, and then he or she has to wait for the response and scroll back to the input field with the error message to fix the problem.

With an AJAX JSF solution, all of this can be addressed with little or no effort from the application developer and a great outcome for the end user. The ADF Faces AJAX RenderKit addresses these issues by asynchronously updating only portions of the page, and by keeping track of the form post (basically controlling whether a form post has occurred). The partial update of the page keeps the scrollbar position and the focus, and provides instant validation of user input.

Using the ADF Faces AJAX RenderKit
Creating an application using the HTML AJAX RenderKit provided by the Apache "ADF Faces" Incubator project is easy. There are two ways of achieving a partial update - declaratively and programmatically. Let's first look at the declarative approach.

Figure 1 illustrates the application we are going to build in this article. It contains a dropdown component that lists a set of JDJ articles and a graphic component that shows the featured images for each article. When an end user accesses this application and selects an article to read, only the image is updated, not the entire page. As shown in Figure 1 this adds the benefit of a kept scrollbar position when the end user changes from one article to another. Furthermore, focus is still set on the dropdown list, allowing the end user to continue to use the dropdown list without the need to reselect it.

The JSP source for the page displayed in Figure 1 in shown in Listing 1. Using the declarative approach, the application developer needs only to ensure that there is a unique identifier for the "triggering' component - <af:selectOneChoice> - in this example selectArticle, and that the component targeted for partial update includes this identifier in the partialTriggers attribute. That's it!

Programmatically Adding a Partial Target
In response to a partial event, only components registered as partial targets are re-rendered. With ADF Faces, application developers can also dynamically add components to the list of partial targets by calling the addPartialTarget method from the AdfFacesContext as shown in the following code.

AdfFacesContext adfContext = AdfFacesContext.getCurrentInstance();
adfContext.addPartialTarget(target);

Let's expand our page with an <af:outputText> component. This component will show an excerpt of each selected article. This time we won't use the declarative approach, instead we'll dynamically add the component to the list of partial targets for the <af:selectOneChoice> component.

In Listing 2, a valueChangeListener has been added to the <af:selectOneChoice>, and a <af:outputText> component has been added underneath <af:selectOneChoice> to provide the excerpt of the selected article. In this case the <af:outputText> component does not include the partialTrigger attribute.

The valueChangeListener in Listing 3 ties it all together by adding the outputText component as the partial target to the selectOneChoice component.

The updated page will now contain a description field that will be part of the partial update when the end user selects an article from the dropdown list.

In Figure 2, note that the scrollbar maintains the same position after the partial postback and that the description has been updated.

The Internal Implementation Design
When a page containing ADF Faces components is accessed for the first time, the initial page render includes a hidden iframe element. This hidden iframe is used to manage the partial update of the page. When a commandButton is clicked, the form is still submitted but targets the hidden iframe instead, and additional information is included in the request to let the AJAX RenderKit detect that a partial response is expected.

During the ApplyRequestValues phase in the Faces Lifecycle, the AJAX RenderKit determines that this is a partial request and decorates the ResponseWriter with a PPRResponseWriter implementation (see Figure 3). The purpose of this is to "clip" the rendered markup to produce only the markup fragments for those components that should be included in the partial response back to the iframe.

Each markup fragment is identified by HTML ID, which is used to find the original section of the HTML DOM that needs to be replaced. Figure 4 shows a DOM inspector and the iframe structure of the partial response for the page created in Listing 2. Note the ID match of each fragment e.g., _id5:selDesc and _id5:selImg.

Challenges Addressed by Choosing <iframe> over XmlHttpRequest
Much of the success of AJAX has come from the widespread availability of XMLHttpRequest (XHR), and many people believe that XHR is a required strategy for AJAX. However, AJAX is simply defined as using native browser technologies (no browser plug-ins) and asynchronous communication with the server. This is also possible to achieve using a hidden iframe, which provides some additional capabilities but with some additional issues as well.

The main functionality that is much more easily supported by the hidden iframe communication channel is file upload. For security reasons, JavaScript executing at the browser is not permitted to read the contents of the local file system. So, when using a plug-in free browser environment, uploading a file from the local file system must leverage the <input type="file" ... > native browser support, which requires the form to be submitted so that the file contents will be sent to the server. Using a hidden iframe allows ADF Faces to target the form submission at the iframe instead of the main document, so that the response from the server is received by the hidden iframe. Of course, the same approach works for any type of form submission, not just file upload input elements.

One of the difficulties introduced by using the hidden iframe communication channel is the problem of knowing when the response is complete. Fortunately, since the PPR response is managed by the AJAX RenderKit, it is straightforward to include an additional script block at the end of the response received by the hidden iframe that will inform the main HTML document when the response is complete. In the rendered response a callback function is added (see Listing 4).

Compatibility with Non-ADF Faces Components
How generic is this functionality? Does it only work with ADF Faces components? What happens when you try to use other components, such as the Apache MyFaces Tomahawk or Tobago component libraries?

Fortunately, the implementation of PPR makes no extra assumptions about the child components of any partial target. If an ADF Faces component is added as a partial target, all of its child components are also re-rendered in the partial response, no matter what component library is used.

Conveniently, any JavaServer Faces component can be added as a partial target using the programmatic API. The PPRResponseWriter will detect when this component is being rendered and ensure that the markup is included in the partial response.

Finally, adding declarative support for any JavaServer Faces component, by adding a partialTriggers attribute, requires only minor modifications to the component API and JSP Tag to expose the attribute and a call to AdfFacesContext.addPartialTriggerListeners in the Renderer.

Conclusion
This is the first successful implementation of AJAX in JSF and, as discussed in this article, is currently used by the ADF Faces component library. This type of architecture relies on a regular form submit. The response is in fragments that contain the information about what is needed for the change. The PPR handler will then figure out where to slot in these changes. This approach is straightforward to use, allowing the application developer to control what components are involved in each partial update. In this architecture, the unit of update is a UIComponent subtree, so the markup for each UIComponent subtree is replaced for each partial target. PPR is also relying on iframes, not XMLHttpRequest, to provide asynchronous communication, which has the benefit of supporting older versions of browsers.

What is interesting is that Oracle announced intentions to donate a new generation of ADF Faces components to the open source community at JavaOne 2006. In contrast to the components discussed in this article, these new components leverage the XMLHttpRequest object to provide AJAX JSF components.

Finally, we believe that MyFaces "ADF Faces" will become the most dominant open source JavaServer Faces component library on the planet. The question is: How will you contribute?

More Stories By Kaazing Blog

Kaazing is helping define the future of the event-driven enterprise by accelerating the Web for the Internet of Things.

More Stories By John Fallows

John brings to Kaazing his 17 years’ experience in technology development and software design, and is considered a pioneer in the field of rich and highly interactive user interfaces. As CTO he formulates Kaazing Corporation’s vision of enabling mobile users, marketplaces and machines to connect and communicate in real-time, more reliably and at unprecedented scale. He defines the architecture of the Kaazing product suite and oversees its development. Prior to co-founding Kaazing, John served as Architect for Brane Corporation, a startup company based in Redwood City, California. Before joining Brane, he was a Consulting Member of Technical Staff for Server Technologies at Oracle Corporation. During his last five years at Oracle, he focused on designing, developing, and evolving Oracle ADF Faces to fully integrate Ajax technologies. Originally from Northern Ireland, he received his MA in Computer Science from Cambridge University in the United Kingdom and has written several articles for leading IT magazines such as Java Developer’s Journal, AjaxWorld Magazine, and JavaMagazine (DE), and is a popular speaker at international conferences. He is co-author of the bestselling book Pro JSF and Ajax: Building Rich Internet Components (Apress).

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
AJAXWorld News Desk 06/14/06 12:51:41 PM EDT

In an effort to provide developers with a productive environment, Oracle has been working on a very rich UI component framework for several years. This framework - ADF Faces - has now been donated to the open source community. More precisely, it has been donated to the Apache Software Foundation and is currently hosted in the Apache Incubator - http://incubator.apache.org/projects/adffaces.html.

@CloudExpo Stories
SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara California. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infras...
SYS-CON Events announced today that Silicon India has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Published in Silicon Valley, Silicon India magazine is the premiere platform for CIOs to discuss their innovative enterprise solutions and allows IT vendors to learn about new solutions that can help grow their business.
Artificial intelligence, machine learning, neural networks. We’re in the midst of a wave of excitement around AI such as hasn’t been seen for a few decades. But those previous periods of inflated expectations led to troughs of disappointment. Will this time be different? Most likely. Applications of AI such as predictive analytics are already decreasing costs and improving reliability of industrial machinery. Furthermore, the funding and research going into AI now comes from a wide range of com...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
SYS-CON Events announced today that Conference Guru has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organi...
SYS-CON Events announced today that GrapeUp, the leading provider of rapid product development at the speed of business, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company, specialized in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market acr...
In this presentation, Striim CTO and founder Steve Wilkes will discuss practical strategies for counteracting fraud and cyberattacks by leveraging real-time streaming analytics. In his session at @ThingsExpo, Steve Wilkes, Founder and Chief Technology Officer at Striim, will provide a detailed look into leveraging streaming data management to correlate events in real time, and identify potential breaches across IoT and non-IoT systems throughout the enterprise. Strategies for processing massive ...
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
"MobiDev is a Ukraine-based software development company. We do mobile development, and we're specialists in that. But we do full stack software development for entrepreneurs, for emerging companies, and for enterprise ventures," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
What's the role of an IT self-service portal when you get to continuous delivery and Infrastructure as Code? This general session showed how to create the continuous delivery culture and eight accelerators for leading the change. Don Demcsak is a DevOps and Cloud Native Modernization Principal for Dell EMC based out of New Jersey. He is a former, long time, Microsoft Most Valuable Professional, specializing in building and architecting Application Delivery Pipelines for hybrid legacy, and cloud ...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
21st International Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Me...
SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
SYS-CON Events announced today that TechTarget has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TechTarget storage websites are the best online information resource for news, tips and expert advice for the storage, backup and disaster recovery markets.
DevOps at Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to w...
You know you need the cloud, but you’re hesitant to simply dump everything at Amazon since you know that not all workloads are suitable for cloud. You know that you want the kind of ease of use and scalability that you get with public cloud, but your applications are architected in a way that makes the public cloud a non-starter. You’re looking at private cloud solutions based on hyperconverged infrastructure, but you’re concerned with the limits inherent in those technologies.
"We focus on composable infrastructure. Composable infrastructure has been named by companies like Gartner as the evolution of the IT infrastructure where everything is now driven by software," explained Bruno Andrade, CEO and Founder of HTBase, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
"Tintri focuses on the Ops side of the DevOps, which basically is pushing more and more of the accessibility of the infrastructure to the developers and trying to get behind the scenes," explained Dhiraj Sehgal of Tintri in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.