"ActionDispatcher: Missing handler for action" error message at client side
My requirement: Send a new custom action called customElementSelected from sprotty client to server when we select any diagram element
export const customSelectorModule = new ContainerModule((bind, _unbind, isBound) => { configureActionHandler({ bind, isBound }, SelectAction.KIND, CustomSelector); });
@injectable() export class CustomSelector implements IActionHandler { @inject(TYPES.IActionDispatcher) actionDispatcher: ActionDispatcher; handle(action: Action): void | Action | ICommand { if (action instanceof SelectAction) { const customAction = new CustomSelectElementAction(action.selectedElementsIDs, action.deselectedElementsIDs); this.actionDispatcher.dispatch(customAction); } } }
I loaded customSelectorModule along with sprotty's required modules.
But CustomSelectElementAction was not sent to server from client when we select diagram element. I can see below error message in the dev console.
Screenshot:

Issue: ActionDispatcher is not handling the CustomSelectElementAction as handler for the action is not registered.
How we can send custom actions from sprotty client to sever? where we have to register handlers?
Hi @sathya-1994,
as you already noticed the problem is that you don't have an action handler for the customElementSelected action registered on the GLSP server. You have to implement a new class that implements the ActionHandler interface and configure it in your diagram module. I recommend to have a look a the custom action handler for LogActions in the workflow example.
Basically you have to implemented these steps:
- Create a new action class for your custom action (see LogAction)
- Implement an action handler for the new custom action (see LogActionHandler)
- Configure the action handler in the
configureActionHandlersof your diagram module (see WorkflowDiagramModule
Once these steps are completed you should be able to send customElementSelected actions from the client to the server.
The client will be automatically informed about available server action handlers on startup so no additional configuration is needed here.
@tortmayr ,
I have configured CustomSelectElementAction at server side(configureActionHandlers() method of GLSP's DiagramModule module).
I have 2 different client one implemented with sprotty(above issue) and other one with GLSP(GLSP server is common both clients).
GLSP client is able to send CustomSelectElementAction to sever through dispatcher(GLSPActionDispatcher).
But sprotty client is not able to send same CustomSelectElementAction action to server through ActionDispatcher(ActionDispatcher: Missing handler for action)
In case sprotty why we are not able to send CustomSelectElementAction ?
Ah sorry my bad. I was addressing a couple of GLSP questions yesterday and overlooked that you posted this question in the sprotty repo :sweat_smile:
I has been quite a while since I worked with the sprotty server, so my knowledge regarding this is a little outdated. @spoenemann Could you please explain how handling custom actions works for the sprotty server usecase?
You need to tell the diagram server proxy in the client that it should handle actions of your custom type so it forwards them to the server. You can do that by overriding the initialize method:
https://github.com/eclipse/sprotty/blob/df4577570c5d95356a4ceb3ecc06754e6a099eec/packages/sprotty/src/model-source/diagram-server.ts#L87-L101