Get static reference to Errai RequestDispatcher in service

80 views Asked by At

I'm trying to upgrade the Errai version in an GWT project. We only use the errai bus, and previously we got the ErraiService from the ServletContext to get the RequestDispatcher and send messages. Upgrading from errai 2.0.Beta2 to 3.0.3, though, that no longer works.

I know that in the client you can get the RequestDispatcher through ErraiBus.getDispatcher(); but that doesn't seem to work on the server code.

How can I statically access the RequestDispatcher from the server without using CDI in order to send a message?

I can see in their source code that:

@Singleton
public class ErraiServiceImpl<S> implements ErraiService<S> {

has a reference to the request dispatcher I need. Is there some wa I can get a reference to a singleton?

1

There are 1 answers

0
CorayThan On BEST ANSWER
ErraiService service = ErraiServiceSingleton.getService();

I had to look in their source code to find this little gem. Not sure why it isn't mentioned anywhere, but it's a great way to use the Errai Bus without their CDI.