AJAX and the progress bar/indicator
While testing on localhost
, AJAX requests seem pretty fast, but in real production environments they cannot be solved as fast because many aspects slow down the process (Internet connection speed, number of concurrent users, and so on).
A common practice consists of using a progress bar/indicator that signals the user that requests are being processed and he/she should wait until the AJAX response is received and rendered accordingly. For example, PrimeFaces provides a cool determinate progress bar for upload tasks (<p:fileUpload>
) and an indeterminate progress indicator for any other AJAX request (check <p:ajaxStatus>
). RichFaces also have similar capabilities.
In the next chapter, you will see how to implement a progress bar for upload tasks. Without writing a custom component, such as <p:ajaxStatus>
, we can easily implement a progress indicator using the onevent
attribute, the data
object, and a small piece of CSS, as shown in the following...