Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type Aliases

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

Type declaration

    • 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.

      Parameters

      Returns void

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

Type declaration

    • 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.

      Parameters

      Returns void

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

Type declaration

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

Type declaration

    • 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.

      Parameters

      Returns boolean | undefined

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

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

PrimeFacesArgs: Record<string, unknown>

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: Record<string, unknown>

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

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

Type Parameters

  • T extends Record<string, unknown> = Record<string, unknown>

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

  • R extends PrimeFacesArgs = PrimeFacesArgs

    Object type of the data returned by the remote command.

Type declaration

    • 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.

      Parameters

      Returns Promise<ResponseData<R>>

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 extends Record<string, unknown> = Record<string, unknown>

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

ShorthandConfiguration: RenameKeys<PrimeFaces.ajax.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

CFG_SHORTCUTS: Record<string, string>

Parameter shortcut mapping for the method PrimeFaces.ab.

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.

RESOURCE: string

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

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

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.

ResponseProcessor: PrimeFaces.ajax.ResponseProcessor

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

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

VIEW_BODY: string

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

VIEW_HEAD: string

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

Functions

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

    deprecated

    Use PrimeFaces.ajax.Request.handle instead.

    Parameters

    • cfg: Partial<PrimeFaces.ajax.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