My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...









[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians


duminică, 3 iulie 2016

[OmniFaces utilities (2.4)] Get a list of all action expressions and listeners associated with given component

[OmniFaces utilities] The getActionExpressionsAndListeners() method returns a list of all action expressions and listeners associated with given component. This covers expressions in action attribute of command components and listener attribute of ajax components. Any method expressions are in format #{bean.method} and any action listeners are added as fully qualified class names. This list is primarily useful for logging postback actions in a phase listener. You can use #getCurrentActionSource() to obtain the current action source.



Let's suppose the following code:

 <h:commandButton value="Foo" actionListener="#{fooBean.fooActionListener()}" action="#{fooBean.fooAction()}">
  <f:setPropertyActionListener id="foo" target="#{}" value="Foo"/>                              
  <f:ajax execute="@form" render="@form" listener="#{fooBean.ajaxFooListener()}"/>

Now, programmatically (for example in a phase listener) we can do this:

import org.omnifaces.util.Components;
// use getCurrentActionSource() to get the source of the currently invoked action
UIComponent command = Components.getCurrentActionSource();
List<String> ael = Components.getActionExpressionsAndListeners(command);

// or, use getCurrentCommand() to get the currently invoked UI command component
UIComponent command = Components.getCurrentCommand();
List<String> ael = Components.getActionExpressionsAndListeners(command);

Both examples will return a List<String>  that contains the following items:


Niciun comentariu :

Trimiteți un comentariu


Postări populare

Visitors Starting 4 September 2015

Locations of Site Visitors