Show loading progress when making JSF Ajax request

前端 未结 2 1179
轻奢々
轻奢々 2020-12-07 23:52

How can I show some loading message when making request using ?

2条回答
  •  遥遥无期
    2020-12-08 00:15

    If you're not already using a 3rd party component library which could already have a ready-made component for that, such as PrimeFaces with , then you can use the JSF-provided JavaScript jsf.ajax.addOnEvent() function (and eventually also jsf.ajax.addOnError()) to hook a function on ajax events.

    Here's a basic kickoff example:

    
    
    
    

    See also chapter 13.3.5.2 of the JSF 2.0 specification:

    13.3.5.2 Monitoring Events For All Ajax Requests

    The JavaScript API provides the jsf.ajax.addOnEvent function that can be used to register a JavaScript function that will be notified when any Ajax request/response event occurs. Refer to Section 14.4 “Registering Callback Functions” for more details. The jsf.ajax.addOnEvent function accepts a JavaScript function argument that will be notified when events occur during any Ajax request/response event cycle. The implementation must ensure the JavaScript function that is registered must be called in accordance with the events outlined in Section TABLE 14-3 “Events”.

    You can grab some cool ajax loader gifs for free from http://www.ajaxload.info, by the way.

提交回复
热议问题