Is it possible to invoke more than one listener method using a single command component? For example,
A view scoped bean:
@ManagedBean
@ViewScoped
pu
-
Use :
Note the importance of the parentheses in EL. Omitting them would in this particular example otherwise throw a confusing javax.el.PropertyNotFoundException: Property 'action' not found on type com.example.ViewScopedBean
, because it's by default interpreted as a value expression. Adding parentheses makes it a method expression. See also Why am I able to bind to an arbitrary method if it's not supported by JSF?
You could even add an actionListener
and/or an action
method to the component the usual way, which is invoked later on. What it has to be unique is the action
method, which decides the outcome for the processing.
Anyway, keep in mind the listeners are always executed before the action and considered a "warming-up" for it. Your best is to perform the whole logic in the action method, even if you need to do bean injections.
See also:
- Call multiple backing bean methods at the same time
- Differences between action and actionListener
讨论(0)
- 热议问题