-
1. Re: CDI Events Across Errai UI Pages
jfuerth Dec 24, 2013 9:51 AM (in response to chaluwa)Hi Charles,
On the client side, Errai's CDI events are delivered to every live object with a matching observer method. In your sample code, you're not declaring a scope on your @Page objects, so they have the default @Dependent scope. This means that only the currently-visible page is live at any given time.
If you want both @Page classes to receive events even when they're not visible, add the @ApplicationScoped annotation to them.
You might also consider factoring out the common state between the two pages into a single @ApplicationScoped bean which is only concerned with state management (rather than a combination of state management and UI). It could still fire events when important changes happen, but then perhaps only the currently-visible page would need to receive the events. Then you can go back to default-scoped pages and hopefully enjoy a more maintainable codebase. :-)
-Jonathan