CDI, Events, Presenter not constructed

I am building an application which is configured for users which have multiple roles. There are a number of views to the application, and I am using the CDI add-on with Vaadin 7.3.2.
In one of the views, there is a table in which the user can select a row. For one particular user role, clicking on a row immediately takes the user to the new view. For another type of user, clicking on a row fires an event (using the fire method of javax.enterprise.event.Event). The observer for this event is the presenter class for the view that is automatically shown for the first type of user role. I’m doing this to allow the second type of user (an admin type of role) to navigate to that view manually if they need to. The problem is, for the admin type user, clicking on the row the first time does indeed fire the event, but since the view/presenter hasn’t actually been instantiated/navigated to, the actions that the observer is supposed to take never happen. Once I navigate to that view and then go back again, the data I had hoped to see is there and then everything works as it should. The purpose of the event is to seed the data for the table that is displayed in the new view.
How do I get the presenter/view to be able to receive events if they haven’t yet been instantiated. Is this a scope issue? Should I be putting the observer in a differnt location (currently in the presenter)?

Here is the clickListener on the table:

private ItemClickListener itemClickListener = new ItemClickListener() {
private static final long serialVersionUID = -3898285764959899825L;

    public void itemClick(ItemClickEvent event) {"In itemClick in {}.", this.getClass().getName());
        if (event.isDoubleClick()) {
            Customer customer = customerTable.getValue();
        } else {
            if (SecurityUtils.getSubject().hasRole("user") || SecurityUtils.getSubject().hasRole("customer service")) {  //shouldn't happen per my new flow...
      "          and is a user.");
                Customer customer = customerTable.getValue();
                if (SecurityUtils.getSubject().hasRole("user")) {

[/code]There is a event observer in my presenter class (which is @UIScoped):

public void onCustomerSelected( @Observes(notifyObserver = Reception.IF_EXISTS) CustomerServiceSelectedEvent event) { Customer customer = event.getCustomer(); getView().populateCustomerLocations(arcustService.findAllLikeCustno(customer.filterList)); } So, again, how do I accomplish this?


You could inject an instance of the view into your UI to ensure an instance is active.


Inject an Instance of your view just before you fire your event, this will better for your UI startup.