Differences between action and actionListener

前端 未结 4 1193
走了就别回头了
走了就别回头了 2020-11-21 04:12

What is the difference between action and actionListener, and when should I use action versus actionListener?

4条回答
  •  爱一瞬间的悲伤
    2020-11-21 05:07

    TL;DR:

    The ActionListeners (there can be multiple) execute in the order they were registered BEFORE the action

    Long Answer:

    A business action typically invokes an EJB service and if necessary also sets the final result and/or navigates to a different view if that is not what you are doing an actionListener is more appropriate i.e. for when the user interacts with the components, such as h:commandButton or h:link they can be handled by passing the name of the managed bean method in actionListener attribute of a UI Component or to implement an ActionListener interface and pass the implementation class name to actionListener attribute of a UI Component.

提交回复
热议问题