I am trying to register a custom action class using Table.addAction() method. The action appears properly when used declaratively in the screen descriptor but that approach was not covering all the needs so I switched to the approach of registering it via addAction().
A first try without any particular action content worked fine, the action appears in the screen as expected. However, when I tried to open a different screen in the action code using ScreenBrowsers service, I got null pointer exceptions as this service was not properly injected.
I looked at the code of EditAction class and it was quite similar to mine. I tried replacing my action with EditAction in my calling screen and got a similar error (on the security service, which was not injected either).
I suppose the problem must be in the creation of the action instance. As suggested by the examples in the documentation, I had used
MyAction action = new MyAction
which looks pretty suspicious now that I know that “action” would not be injected with its dependencies.
Is there a better way to instantiate MyAction, which ensures it is also injected with the dependencies?