How to Use Actions
by, 04-26-2012 at 07:48 PM (364 Views)
For separation of the state and functionality from component, an action is used. For instance, if there are 2 or more than 2 components which perform similar kind of functions, an Action object shall be considered for implementation of the function. An action object act as action listener which assist action event handling as well as centralized handling for component of action event firing state. For example, text fields, common buttons, menu items and tool bar buttons. The state which can be handled by an action include selected status, icone, text etc.
Typically, an action is attached to a component by usage of the setAction method. On a component, invoking a setAction results into following:
- State of components gets updated so that state of action could be matched. For instance, icon and text of the action are set then icon and text of component is also set, to those values.
- On the component, action object has been registered, as action listener.
- If alteration takes place in state of action, update state of component to match action.