5 Replies Latest reply on Jan 20, 2014 3:36 PM by Christian Sadilek

    Errai CDI Injection Question

    Matt Parker Newbie

      I'm having trouble injecting an object to send new events in a GWT widget.

       

      I started with the Errai tutorial, and have modified to use OpenLayers GWT project. I would have to track certain

      map events, sending them to a backend service for processing.

       

      I used what is the standard example from the CDI documentation.

       

      I using the entire Errai stack, defining the following in my gwt.xml file:

       

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

       

      I have a GWT widget with the following mapChanged variable to send events:

       

      public class MapView extends DockPanel {
      
          @Inject
          Event<MapChangedEvent> mapChanged;
      
          public MapView() {
      
              if ( mapChanged == null ){
                  GWT.log("New: mapchanged is null");
              }
            
           }
      
      }
      
      

      where the GWT.log reports that mapChanged is null.

       

      This is trying to communicate with a server side entity, defined like the following:

       

      @ApplicationScoped
      public class MapModelService {
      
          private static Logger log = LoggerFactory.getLogger(MapModelService.class);
        
          public void userChangedMapView( @Observes MapChangedEvent event ){
              log.info("User Changed Map VIew: Event recieved " + event.getEventType() );
          }
        
      }
      
      

       

      with the following event object to transfer the data:

       

      @Portable
      public class MapChangedEvent {
      
          public MapChangedEvent(){
            
          }
      
      }
      
      

       

      I'm not sure why mapChanged continues to be null at startup.

       

      TIA,

       

      Matt