What is the difference between actionlistener and action?
What is the difference between actionlistener and Action ? When to use one or the other?
<h:commandButton action="xxxx" actionListener="zzzz" id="teste"/>
1 answers
Although you can use them in the same way ( perform actions ), I think the best question is "when" to use one in spite of another.
Action
You should use an action if your intention is to run a business logic or navigate between pages . The action method can return a string indicating the navigation rule.
Actionlistener
You should use an actionListener if what you want to do is execute a view-related logic or trigger an action before a business logic. the logic invoked by an actionListener is more tied to screen details than purely business rules.
Not to be in the 'copy-paste', http://blog.triadworks.com.br/quando-usar-action-ou-actionlistener-com-jsf