What is the difference between actionlistener and action?

Asked

Viewed 445 times

0

What’s the difference between actionListener and action? When using one or the other?

<h:commandButton action="xxxx" actionListener="zzzz" id="teste"/>
  • In what context?

  • <h:commandButton action="xxxx" actionListener="zzzz" id="teste"/>

  • Edit the question and add it directly to it so it doesn’t get vague and close.

  • 2

    Answer:Differences between action and actionListener if you know English, this link has a very complete explanation of the differences between them and when to use one or the other.

  • The link is pointing to the same question

  • opa, corrected.

Show 1 more comment

1 answer

1

Although you can use them in the same way ( perform actions ), I think the better question is "when" to use one despite another.

Action

You should use an action if your intention is 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-glue', http://blog.triadworks.com.br/quando-usar-action-ou-actionlistener-com-jsf

Browser other questions tagged

You are not signed in. Login or sign up in order to post.