2 Replies Latest reply on Nov 8, 2013 10:45 AM by Varghese Cottagiri

    Issue when injecting client components

    Varghese Cottagiri Newbie

      I was playing around with the HelloWorld example to get familiar with the Errai API, In particular the client components injection.

       

      1. @EntryPoint
      2. public class HelloWorldClient extends VerticalPanel {
      3.     @Inject
      4.     private MessageBus bus;
      5.     ...
      6.     void sendMessage() {
      7.         MessageBuilder.createMessage()
      8.                       .toSubject("HelloWorldService")
      9.                       .signalling()
      10.                       .withValue(message.getText())
      11.                       .noErrorHandling()
      12.                       .repliesTo(new MessageCallback() {
      13.                           @Override
      14.                           public void callback(Message message) {
      15.                               System.out.println("Server responded with :" + message.getParts().get("text"));
      16.                           }
      17.                       })
      18.                       .sendNowWith(bus);
      19.     }
      20. }

       

      The above code snippet does not send any request to the server side.

      If I change line number 18 to "sendNowWith(ErraiBus.get())" it works and I see the sysouts from the client and server side.

      What is amiss here?

       

      I am on errai-2.4.2.FINAL and gwt-2.5.1

        • 1. Re: Issue when injecting client components
          Christian Sadilek Master

          Hi,

           

          This should definitely work. Can you check if the injected bus instance is null? To be able to @Inject the bus you will either need to inherit from the errai-cdi or errai-ioc-bus-support module (or inherit it transitively through the errai-javaee-all module):

           

          <inherits name="org.jboss.errai.ioc.support.bus.BusSupport" />
          

           

          or

           

          <inherits name="org.jboss.errai.enterprise.CDI" />
          

           

          Can you maybe post your gwt.xml file?

           

          Cheers,

          Christian

          • 2. Re: Re: Issue when injecting client components
            Varghese Cottagiri Newbie

            Thanks Christian, adding org.jboss.errai.ioc.support.bus.BusSupport to gwt.xml, I also had to add errai-ioc-bus-support to maven's dependency list.

             

            The gwt.xml now looks like this

             

            <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6//EN"
                            "http://google-web-toolkit.googlecode.com/svn/releases/1.6/distro-source/core/src/gwt-module.dtd">
            <module rename-to="HelloWorld">
                <inherits name='com.google.gwt.user.User'/>
                <inherits name="org.jboss.errai.bus.ErraiBus"/>
                <inherits name="org.jboss.errai.ioc.Container"/>
                <inherits name="org.jboss.errai.ioc.support.bus.BusSupport" />
            </module>