Why Actions are better than click-listeners?
- Actions resolve to insertion of an ActionView, instead of literal HTML.
- ActionView can be overwritten from the (sub)Context.
- This makes it easier to white-label or change the Look & Feel of an application or just part of an application.
- This even makes it possible to do more complex stylings that could be accomplished with just CSS. For example, the Material Design calculator uses canvas views to render and animate buttons, which could not be done with just CSS.
- ActionView also provides:
- multi-lingual support
- keyboard shortcut navigation
- accessibility features like text-to-speech labels
- tab ordering
- Actions support isEnabled() and isAvailable(), which are expressions and can change dynamically. If you use an ActionView it will automatically disable or hide the action based on your specified logic.
So, for a simple example of when some action is performed when someone clicks on a button, onclick looks fine, but once you add business logic for enabling and hiding, multi-lingual messages, support for screen readers, keyboard navigation, customizability, permission checks, etc. then you realize the "simple" task of drawing a button and adding an onclick listener can in fact require pages of code.