Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to learn the primefaces javascript API?

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:

  1. What are the input variable xhr, status, args and where are they defined, and where do they get their values from?
  2. Is this the only handler I need to use with jsf components events such as onBlur or onClick, and how can I learn them?
  3. Is there any documentation for this? I came from Java SE where every thing is documented and explained, where to look for javascript documentations and how?

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.

like image 861
alibttb Avatar asked Aug 24 '16 17:08

alibttb


People also ask

What is PrimeFaces Javascript?

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" />

What is PF in PrimeFaces?

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'] .


1 Answers

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.

like image 76
Sensei James Avatar answered Sep 19 '22 17:09

Sensei James