AJAX components

Javaâ„¢ Widget Library (JWL) AJAX Components are used to dynamically replace the content of a panel tag within a page without replacing the page in the browser window. These tags allow a more seamless, flicker-free user interface. User interactions with a page no longer need to submit/request entire pages, instead, pieces of the page can change as data is entered.

JWL AJAX tags are added as child tags of any of the JWL panel tags. Their content defines an alternative content for the panel. When the tag is actioned by a JWL get action (that is, a JavaScriptâ„¢ event such as click invokes the JWL get action), a request is made back to the server for the new content to put in the panel. The server computes the new content (updating the tree of objects in the page if need be), returns the content to the client where it is plugged into the panel, replacing its existing content.

In requesting content from the server, the AJAX components can either do a HTTP get (sub)request or a HTTP submit (sub)request. They can either request content or they can submit the form enclosing the panel and receive back the panel that results in the processing of the submit. ajaxRefreshRequest does a get where the additional content is defined in the same page that created the page. ajaxUpdateContent does a submit, again, where the additional content is defined in the same page that created the page. ajaxRefreshRequest can pass parameters from the client to the server in order to direct how/what content is generated. A third AJAX component, ajaxExternalRequest can be used to request content from a source other than the originating JSF page.

When using ajaxRefreshRequest and ajaxUpdateContent, you can think of these tags as simply defining alternate content within a panel tag. A panel has its initial content and then additional content defined by the AJAX tag embedded within it. Initially it displays the initially content. When client code actions the tag, the initial content is replaced by the additional content defined by the AJAX tag.

Adding only a JWL AJAX tag to the page does not do anything. In order for the page to receive new content, you must code at least one JWL get action into the page. The get action causes the new content, defined by the AJAX tag, to be retrieved.

The available AJAX tags are:

Components that are initially hidden on the palette are denoted by an asterisk (*) next to their name in the tables.

Table 1. AJAX components
Component Tag Name Description
Get Content <hx:ajaxRefreshRequest> Define how content from the same JSF page replaces the existing content of the parent tag. Content is retrieved using an HTTP get (sub)request.
Update Content <hx:ajaxRefreshSubmit> Define how content from the same JSF page replaces the existing content of the parent tag. Content is retrieved using an HTTP submit (sub)request.
Get External Content <hx:ajaxExternalRequest> Define how content from a different page replaces the content of the parent tag. Content is retrieved using an HTTP get (sub)request against an arbitrary data source.
Related concepts
Asynchronous JavaScript and XML (AJAX) Components
JavaServer Faces (JSF) overview
JSF Widget Library (JWL)
Developing Web applications using JavaServer Faces (JSF)

Feedback