Monday, April 14, 2014

Why canReveal() of GateKeeper was called before the EventHandler was called (GWT)?

I got a Header presenter which is the nested presenter. The Customer presenter is the child of Header presenter (ie the Customer presenter was put into a slot of Header presenter).

So I want to use MyGateKeeper to manage login page. The HeaderPresenter that will fire PassUserInfoEvent.

public class MyGateKeeper implements Gatekeeper{  private String loginedUserID="";    private final EventBus eventBus;    @Inject  public MyGateKeeper (final EventBus eventBus){        this.eventBus = eventBus;          this.eventBus.addHandler(PassUserInfoEvent.getType(), new PassUserInfoHandler(){            @Override          public void onPassUserInfo(PassUserInfoEvent event) {              // TODO Auto-generated method stub              String userID=event.getUserID();              loginedUserID=userID;             }        });  }    @Override  public boolean canReveal(){      System.out.println(loginedUserID+"Test");      if(!loginedUserID.equals("")){          System.out.println(loginedUserMeaningID+"cxcxc");          return true;      }      else{          return false;      }  }  

}

In the CustomerPresenter:

@ProxyCodeSplit  @NameToken(NameTokens.cust)  @UseGatekeeper(MyGateKeeper.class)  public interface MyProxy extends ProxyPlace<CustomerPresenter> {  }  

However after run, it does not show the Gui even I loggined. I tested & found that canReveal() in MyGateKeeper was called before PassUserInfoHandler() was called, so canReveal never return true;

How to fix this problem?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment