While learning JSF-2.2 with PrimeFaces 5.3 I came across javascript events handlers like the one used with onComplete
attribute:
function handelSmptmSaveRequest(xhr, status, args) {
if (args.validationFailed) {
PF('smptmDlgWv').jq.effect("shake", {
times : 5
}, 100);
} else {
PF('smptmDlgWv').hide();
}
}
I have multiple questions here:
xhr, status, args
and where are they defined, and where do they get their values from?onBlur
or onClick
, and how can I learn them?Edit1 This appears to be Ajax callbacks defined by PrimeFaces, and They're announced here http://blog.primefaces.org/?p=830 but there is still a problem, though the PF showcase has some examples of usage, but I can't fine do documentation for these functions, I'm adding ajax tag for the question.
PrimeFaces is a global library that adds methods and constants in the global window scope. To use the type declarations in a JavaScript or TypeScript file, use a triple-slash directive like this (must be at the top of the file): /// <reference path="./path/to/PrimeFaces.d.ts" />
PF is a shortcut for PrimeFaces. widgets['someWidgetId'] , which just looks-up a Javascript object in global scope, and so the Javascript object can also be retrieved using window['someWidgetId'] .
Here is the PrimeFaces 5.3 documentation, in PDF form. (Here are docs for all versions.)
Page 536 documents the parameters for the oncomplete(xhr, status, args)
function:
Javascript callback to process when ajax request completes. Takes three arguments, xmlhttprequest, status string and optional arguments provided by RequestContext API.
XMLHttpRequest
is the vanilla JS Object that we all know and love.
RequestContext
is defined on page 588 of the PrimeFaces 5.3 documentation:
RequestContext is a simple utility that provides useful goodies such as adding parameters to ajax callback functions. RequestContext is available in both ajax and non-ajax requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With