[OmniFaces utilities] The
getCurrentActionSource()
method returns the source of the currently invoked action, or null
if there is none, which may happen when the current request is not a postback request at all, or when the view has been changed by for example a successful navigation. If the latter is the case, you'd better invoke this method before navigation.Method:
Usage:
import org.omnifaces.util.Components;
...
UIComponent action = Components.getCurrentActionSource();
You can see several examples of using this method as:
- check whether the given component has invoked the form submit (hasInvokedSubmit()):
public static
boolean hasInvokedSubmit(UIComponent component) {
UIComponent source = getCurrentActionSource();
return source != null &&
source.equals(component);
}
- get the currently invoked UI command component (getCurrentCommand()):
public
static UICommand getCurrentCommand() {
UIComponent source = getCurrentActionSource();
return source instanceof UICommand ?
(UICommand) source : null;
}
Niciun comentariu :
Trimiteți un comentariu