Message action
Message/action is a way to support communication between widget to widget, widget to framework, and framework to widget. To learn about the message/action concept, see core concepts.
Publishing a message
A widget calls MessageManager.getInstance().publishMessage(message)
to publish a message. For example, the List
widget publishes the DataRecordsSelectionChange
message when a list item is
clicked or a Map
widget publishes the ExtentChange
message when the view is changed, which updates the List
widget content. The following MessageTypes
are supported:
StringSelectionChange
ExtentChange
DataRecordsSelectionChange
DataRecordSetCreate
DataRecordSetUpdate
To publish a message, a widget should declare the published messages in the manifest.json
file.
Creating a message action
To create a message action, you will need to extend AbstractMessageAction
class. There are several methods and functions that help with developing message actions.
The filterMessageType
method is used to filter the available actions.
filterMessage
method is used to filter messages in message manager.
The getSettingComponentUri
component can be used to configure the action based on the message.
onExecute
method handles the logic for what you would like to happen for your message type. In the snippet below, it basically selects the action based on the message type and sends it from the application to the store using getAppStore()
function using the dispatch
property. This dispatches the redux action
and allows the state to be updated. Learn more about redux actions and using the store in Redux.