开发者

How to prevent code to execute after firing of history token in gwt?

开发者 https://www.devze.com 2023-04-04 06:44 出处:网络
I am working on gwt2.3 application with gwtp framework.In this application I am have one login (index) page which is bind by the client module.

I am working on gwt2.3 application with gwtp framework.In this application I am have one login (index) page which is bind by the client module.

bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.login);

Now after successfull login a new name token name user page is fired.

     History.newItem(NameTokens.userconsole,true);

Now I have my history handler like below:

public class NameTokenHandler implements ValueChangeHandler {

@Override
public void onValueChange(final ValueChangeEvent<String> event) {
    System.out.println("Nothing to do");
}

}

And I added to History like below in entry point class:

History.addValueChangeHandler(开发者_JS百科new NameTokenHandler());

Now as I have overridden the onValueChange method & I have left it blank.

So when application loads first or any other name token fires it should invoke onValueChange first and as there no code in this method nothing should be load.

But in application it is working fine. All the name tokens are firing successfully even after there is no code in onValueChange. I am not getting how to prevent the firing of history token?

Please help me out.

Thanks in advance.


So when application loads first or any other name token fires it should invoke onValueChange first and as there no code in this method nothing should be load.

If you are using gwtp History ValueChangeHandler will not prevent or enable navigation to a particualr part of your application. That is all handled with PlaceManager.


After some googling I came to know about place manager. I am adding_ a change handler to History. All the change handlers that have been added already are still there. In particular, the one in GWTP's PlaceManagerImpl constructor.

If you really want to prevent some history events from being handled by GWTP, I would suggest that, in your custom PlaceManager, you override onValueChange(...), intercept the tokens you want to block, and call the parent's onValueChange for the tokens you want GWTP to handle normally.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号