[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.Method:
Usage:
Let's suppose the following code:
<h:form>
<h:commandButton value="Foo" actionListener="#{fooBean.fooActionListener()}"
action="#{fooBean.fooAction()}">
<f:setPropertyActionListener id="foo"
target="#{fooBean.foo}" value="Foo"/>
<f:ajax execute="@form"
render="@form" listener="#{fooBean.ajaxFooListener()}"/>
</h:commandButton>
</h:form>
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:
[
#{fooBean.fooAction()},
javax.faces.event.MethodExpressionActionListener,
com.sun.faces.facelets.tag.jsf.core.SetPropertyActionListenerHandler$SetPropertyListener,
#{fooBean.ajaxFooListener()}
]






Arrays
Converters

JSF 2 Tutorials at www.mkyong.com
JavaServer Faces (JSF) Tutorial 


















Niciun comentariu :
Trimiteți un comentariu