Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

[OmniFaces utilities (2.4)] Get the source of the currently invoked action


[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;
}

API GH


This post first appeared on OmniFaces & JSF Fans, please read the originial post: here

Share the post

[OmniFaces utilities (2.4)] Get the source of the currently invoked action

×

Subscribe to Omnifaces & Jsf Fans

Get updates delivered right to your inbox!

Thank you for your subscription

×