-
1. Re: Problem with errai Event
csa Jun 25, 2013 11:17 AM (in response to hernsys)Hi Horacio,
I'd like to look into this but I need some more information. It looks like your event should be fired and observed on the client (fired in one GWT module and observed by another). Is this correct? Does one of your GWT modules inherit the other? Do both modules have an ErraiApp.properties?
Which module defines your event type (HumanEventSummary)?
Cheers,
Christian
-
2. Re: Problem with errai Event
hernsys Jun 25, 2013 12:27 PM (in response to csa)Hello Christian
The application has many modules.
One module(module1 with **Client.gwt.xml) has a @Observes
public void saveNewEventHistory(@Observes HumanEventSummary pointHistory) { //my code }
The other modules invoke this @Observes
@Inject
private Event pointHistoryEvent;
pointHistoryEvent.fire(new HumanEventSummary(ActionHistoryEnum.TASK_CREATED));
All the modules have a ErraiApp.properties and this modules have in your pom.xml dependencies of the module1 and this have dependencies with module2.
HumanEventSummary is defined in module2 and this module have your **API.gwt.xml
The xmls is inherit from other modules
<inherits name="**API.gwt.xml"/>
<inherits name="**Client.gwt.xml"/>
Definition
@Portable
public class HumanEventSummary implements Serializable{...}
Thanks
-
3. Re: Problem with errai Event
csa Jun 25, 2013 1:24 PM (in response to hernsys)Hi Horacio,
I created a quick example which works fine for me (attached as a zip file). It has 3 modules, a module that fires an event, a module that observes an event, and a main module with an EntryPoint that causes the event to get fired in Module1 and observed in Module2.
To test it, you need to mvn clean install Module1 and Module2, then run mvn clean gwt:run on module-main.
Hope that helps tracking down the problem.
Cheers,
Christian
-
errai-cdi-event-multimodule.zip 121.2 KB
-
-
4. Re: Problem with errai Event
hernsys Jun 28, 2013 2:08 PM (in response to csa)Christian, thank you for your time and sorry for my delay in responding.
The problem was solved but i am worried by the way I did it.
In the other modules, it only works if I @Inject the class that have the @Observes, otherwise it does not work.
My concern is that I am not having decoupling with other modules.
any suggestions?
Thanks
-
5. Re: Problem with errai Event
csa Jun 28, 2013 4:10 PM (in response to hernsys)1 of 1 people found this helpfulHi,
Yes, for @Observes to work the bean needs to be managed by Errai's IOC container. Another option you have is to create a bean instance programmatically (instead of having it injected):
https://docs.jboss.org/author/display/ERRAI/Client-Side+Bean+Manager
This should help you address the coupling issue.
Cheers,
Christian
-