Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

CallbackOncomplete

CallbackOncomplete: (this: AjaxSettings, xhrOrErrorThrown: unknown, status: TextStatus, pfArgs: PrimeFacesArgs, dataOrXhr: XMLDocument | pfXHR) => void

Callback for an AJAX request that is always called after the request completes, irrespective of whether it succeeded or failed.

This is the type of function that you can set as a client side callback for the oncomplete attribute of a component or an AJX behavior.

Type declaration

    • Parameters

      • this: AjaxSettings
      • xhrOrErrorThrown: unknown

        Either the XHR request that was made (in case of success), or the error that was thrown (in case of an error).

      • status: TextStatus

        The type of error or success.

      • pfArgs: PrimeFacesArgs

        Additional arguments returned by PrimeFaces, such as AJAX callback params from beans.

      • dataOrXhr: XMLDocument | pfXHR

        Either the XMLDocument (in case of success), or the XHR request (in case of an error).

      Returns void

CallbackOnerror

CallbackOnerror: (this: AjaxSettings, xhr: pfXHR, status: ErrorTextStatus, errorThrown: string) => void

Callback for an AJAX request that is called in case any error occurred during the request, such as a a network error. Note that this is not called for errors in the application logic, such as when bean validation fails.

This is the type of function that you can set as a client side callback for the onerror attribute of a component or an AJX behavior.

Type declaration

CallbackOnstart

CallbackOnstart: (this: Request, cfg: Configuration) => boolean

Callback for an AJAX request that is called before the request is sent. Return false to cancel the request.

This is the type of function that you can set as a client side callback for the onstart attribute of a component or an AJX behavior.

Type declaration

    • Parameters

      Returns boolean

      false to abort and not send the request, true or undefined otherwise.

CallbackOnsuccess

CallbackOnsuccess: (this: AjaxSettings, data: XMLDocument, status: SuccessTextStatus, xhr: pfXHR) => boolean | undefined

Callback for an AJAX request that is called when the request succeeds.

This is the type of function that you can set as a client side callback for the onsuccess attribute of a component or an AJX behavior.

Type declaration

    • Parameters

      • this: AjaxSettings
      • data: XMLDocument

        The XML document representing the partial response returned the JSF application in response to the faces request. It usually looks like this: <changes>...</changes>

      • status: SuccessTextStatus

        The type of success, usually success.

      • xhr: pfXHR

        The XHR request that succeeded.

      Returns boolean | undefined

      true if this handler already handle and/or parsed the response, false or undefined otherwise.

ConfigurationExtender

ConfigurationExtender: Pick<Configuration, "update" | "process" | "onstart" | "params" | "onerror" | "onsuccess" | "oncomplete"> & { partialSubmitParameterFilter: any }

Additional options that can be passed when sending an AJAX request to override the current options.

PrimeFacesArgs

PrimeFacesArgs: Record<string, any>

An entry on the JQuery.jqXHR request object with additional values added by PrimeFaces. For example, when you call PrimeFaces.current().ajax().addCallbackParam(...) on the server in a bean method, the added parameters are available in this object. This is also how you can access pass values from the server to the client after calling a remote command. See PrimeFaces.ajax.pfXHR and PrimeFaces.ab.

PrimeFacesSettings

PrimeFacesSettings: Record<string, any>

Additional settings on a JQuery.jqXHR request, such as portlet forms and nonces.

RemoteCommand

RemoteCommand<T, R>: (params?: RemoteCommandParams<T>) => Promise<ResponseData<R>>

Type for the JavaScript remote command function that is created via

<p:remoteCommand name="myCommand" listener="#{myBean.action}" />

This creates a variable window.myCommand that is of this type. On the client-side, you can pass parameters to the remote command via

window.myCommand([ { name: "myParamName", value: 9 } ]);

On the server-side, you can access them as follows:

String myParamValue = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("myParamName")

To send data back to the client, use

PrimeFaces.current().ajax().addCallbackParam("returnParamName", true);

Finally, to access the returned value on the client, do

try {
  const response = await window.myCommand([ { name: "myParamName", value: 9 } ]);
  // Success, do something with the data
  const value = response.jqXHR.pfArgs.returnParamName;
}
catch (e) {
  // Handle error
  console.error("Could not invoke remote command", e);
}

Please note that you should not use async-await if you need to target old browsers, use then/catch on the returned promise instead. See RemoteCommandParams for more details on how to use this TypeScript type.

Type parameters

  • T: Record<string, any> = Record<string, any>

    Object type with the param names and the corresponding param values.

  • R: PrimeFacesArgs = PrimeFacesArgs

    Object type of the data returned by the remote command.

Type declaration

    • Parameters

      • Optional params: RemoteCommandParams<T>

        Optional parameters that are passed to the remote command.

      Returns Promise<ResponseData<R>>

      A promise that is settled when the remote command it complete. It is resolved with the data received from the server, and rejected when a network or server error occurred.

RemoteCommandParams

RemoteCommandParams<T>: {[ P in keyof T]: P extends string ? RequestParameter<P, T[P] extends infer R[] ? R : T[P]> : never }[keyof T][]

Helper type for the parameters of the remote command. You can specify an object type with the allowed parameter names and their expected value types. This helps to increase type safety for remote commands. For example, when this remote command with an appropriate bean implementation is defined:

<p:remoteCommand name="RemoteCommands.checkMaturity" ... />

Then you can declare (or generate automatically from the bean method!) this remote command in TypeScript like this:

declare const RemoteCommands {
  const checkMaturity: RemoteCommand<
    {name: string, age: number},
    {success: boolean, message: string}
  >;
}

RemoteCommand.checkMaturity( [ { name: "name", value: "John Doe" } ] ) // works
RemoteCommand.checkMaturity( [ { name: "age", value: 12 } ] ) // works

RemoteCommand.checkMaturity( [ { name: "username", value: "John Doe" } ] ) // error
RemoteCommand.checkMaturity( [ { name: "age", value: "12" } ] ) // error

const response = await RemoteCommand.checkMaturity( [ { name: "name", value: "John Doe" } ];

const success: boolean = response.jqXHR.pfArgs.success; // works
const message: string = response.jqXHR.pfArgs.message; // works
const message: string = response.jqXHR.pfArgs.errormessage; // error
returns

An array type of request parameters where the name can be one of the keys of T and the value is the corresponding value from T. Array values are mapped to the item type, so that RemoteCommandParams<{names: string[]}> is the same as RemoteCommandParams<{names: string}>. This is done because multiple values for the same name should be send by including multiple items in the request callback parameter array.

Type parameters

  • T: Record<string, any> = Record<string, any>

    Record type with the param names and the corresponding param values.

ShorthandConfiguration

ShorthandConfiguration: RenameKeys<Configuration, { async: "a"; delay: "d"; event: "e"; formId: "f"; fragmentId: "fi"; global: "g"; ignoreAutoUpdate: "iau"; oncomplete: "onco"; onerror: "oner"; onstart: "onst"; onsuccess: "onsu"; params: "pa"; partialSubmit: "ps"; partialSubmitFilter: "psf"; process: "p"; resetValues: "rv"; skipChildren: "sc"; source: "s"; timeout: "t"; update: "u" }>

Options passed to AJAX calls made by PrimeFaces. This is the same as Configuration, but with shorter option names and is used mainly by the method PrimeFaces.ab. See Configuration for a detailed description of these options.

Variables

Let CFG_SHORTCUTS

CFG_SHORTCUTS: Record<string, string>

Parameter shortcut mapping for the method PrimeFaces.ab.

Const Queue

Queue: Queue

This object contains functionality related to queuing AJAX requests to ensure that they are (a) sent in the proper order and (b) that each response is processed in the same order as the requests were sent.

Const RESOURCE

RESOURCE: string

Name for the ID of a resource entry, used in AJAX requests.

Const Request

Request: Request

The interface for the object containing low-level functionality related to sending AJAX requests.

Const Response

Response: Response

The interface for the object containing low-level functionality related to handling AJAX responses. Note that the different types of AJAX actions are handles by the PrimeFaces.ResponseProcessor.

Const ResponseProcessor

ResponseProcessor: ResponseProcessor

The interface for the object containing low-level functionality related to processing the different types of actions from AJAX responses.

Const Utils

Utils: Utils

This object contains utility methods for AJAX requests, primarily used internally.

Const VIEW_BODY

VIEW_BODY: string

Name for the ID of the BODY element, used in AJAX requests.

Const VIEW_HEAD

VIEW_HEAD: string

Name for the ID of the HEAD element, used in AJAX requests.

Functions

AjaxRequest

  • Only available for backward compatibility, do not use in new code.

    deprecated

    Use PrimeFaces.ajax.Request.handle instead.

    Parameters

    • cfg: Partial<Configuration>

      Configuration for the AJAX request to send, such as the HTTP method, the URL, and the content of the request.

    • Optional ext: Partial<ConfigurationExtender>

      Optional extender with additional options that overwrite the options given in cfg.

    Returns undefined

    Always returns undefined.

Generated using TypeDoc