sâmbătă, 12 decembrie 2015

[OmniFaces utilities 2.3] Check if the current request is an ajax request with partial rendering


[OmniFaces utilities] The isAjaxRequestWithPartialRendering() returns whether the current request is an ajax request with partial rendering. That is, when it's an ajax request without render="@all".

Method:
Usage:

If you don't want to pass in the FacesContext, use it from Faces as below:

import org.omnifaces.util.Faces;
...
boolean isARPR = Faces.isAjaxRequestWithPartialRendering();

If you want to pass in the FacesContext, use it from FacesLocal as below:

import org.omnifaces.util.FacesLocal;
...
boolean isARPR = Faces.isAjaxRequestWithPartialRendering(facesContext);

This method returns false for a non-AJAX request or an AJAX request like below:

<f:ajax render="@all"/>

Niciun comentariu:

Trimiteți un comentariu