PrimeFaces Ajax Callbacks [ (xhr, status, args) ]
2015-12-10 19:13
302 查看
PrimeFaces partial page rendering feature is powered by JSF 2.0′s standard Ajax APIs with some of our own extensions. One of these extensions is the client side callbacks for ajax request, standard f:ajax has onerror and onevent whereas PrimeFaces provides
onerror, onsuccess, onstart and oncomplete so when do these callbacks are executed?
onstart()
Before the ajax request is sent, xhr object is passed as a parameter and if you return false you can cancel the request. Also if the component that fires the ajax request supports onclick, that would be an alternative.
onerror(xhr, status, exception)
Fired when something goes wrong on server side, it gets three parameters xhr is the request object, status is the status response as string and exception is the object containing detailed information about the error.
onsuccess(xml)
Executed when server returns the partial output in xml format but before it is processed for dom update, this is handy if you’d like to parse the xml in your own. If you return false, you can cancel default dom update process.
oncomplete(xhr, status, args)
This is the most popular callback that is used, fired when response is received and dom is updated, it gets three parameters, xhr is the request object, status is the response status as string and args is the optional callback parameters that are passed from
server as JSON using PrimeFaces RequestContext API. I’ll create a detailed post about how to use the handy args feature soon.
onerror, onsuccess, onstart and oncomplete so when do these callbacks are executed?
onstart()
Before the ajax request is sent, xhr object is passed as a parameter and if you return false you can cancel the request. Also if the component that fires the ajax request supports onclick, that would be an alternative.
onerror(xhr, status, exception)
Fired when something goes wrong on server side, it gets three parameters xhr is the request object, status is the status response as string and exception is the object containing detailed information about the error.
onsuccess(xml)
Executed when server returns the partial output in xml format but before it is processed for dom update, this is handy if you’d like to parse the xml in your own. If you return false, you can cancel default dom update process.
oncomplete(xhr, status, args)
This is the most popular callback that is used, fired when response is received and dom is updated, it gets three parameters, xhr is the request object, status is the response status as string and args is the optional callback parameters that are passed from
server as JSON using PrimeFaces RequestContext API. I’ll create a detailed post about how to use the handy args feature soon.
相关文章推荐
- primeFaces中 <p:dataList>简单使用
- primefaces中<p:fileDownload>控件的使用
- What does the PF function do in Primefaces
- PrimeFaces 核心源码 js
- Programatically Adding Ajax Actions to UIComponents
- PrimeFaces 4.0 使用 <p:fileDownload> 标签实现文件下载
- 通过 <p:commandButton> 的 oncomplete 属性实现其它按钮的激活与反激活
- primefaces frozenColumns width
- primefaces dataExporter export invisible dataTable rows
- JSF 2.0(基于Primefaces 3.4.2) 中文乱码的处理方案
- Primefaces 中e.offset(...)问题的处理
- PrimeFaces双击表格行跳转到新页面
- PrimeFaces Table 自动换行
- Primefaces Table 选中行时不消除已选中的Checkbox
- JSF级联操作使用开源类库PrimeFaces之autoCompelte
- Primefaces+JSF中页面组件update刷新问题,求大神解惑!
- primeFaces标签无法正常显示
- 理解PrimeFaces process/update和JSF f:ajax execute/render属性
- primmefaces遍历map
- 从Richfaces 4.5迁移到Primefaces 6.2