简体   繁体   English

如何在gwt中触发历史令牌后阻止代码执行?

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

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. 我正在使用gwtp framework在gwt2.3应用程序上工作。在此应用程序中,我有一个登录(索引)页面,该页面由客户端模块绑定。

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 { 公共类NameTokenHandler实现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”添加到如下所示:

History.addValueChangeHandler(new NameTokenHandler());

Now as I have overridden the onValueChange method & I have left it blank. 现在,由于我重写了onValueChange方法,因此将其留空。

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. 因此,当应用程序首先加载或触发任何其他名称令牌时,应首先调用onValueChange,并且由于此方法中没有代码,因此不应加载任何内容。

But in application it is working fine. 但是在应用程序中它运行良好。 All the name tokens are firing successfully even after there is no code in onValueChange. 即使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. 因此,当应用程序首先加载或触发任何其他名称令牌时,应首先调用onValueChange,并且由于此方法中没有代码,因此不应加载任何内容。

If you are using gwtp History ValueChangeHandler will not prevent or enable navigation to a particualr part of your application. 如果您使用的是gwtp,则 ValueChangeHandler不会阻止或启用导航到应用程序特定部分的功能。 That is all handled with PlaceManager . 全部由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. 特别是GWTP的PlaceManagerImpl构造函数中的一个。

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. 如果您确实想防止GWTP处理某些历史记录事件,建议您在自定义的PlaceManager中重写onValueChange(...),拦截要阻止的令牌,并为令牌调用父级的onValueChange您希望GWTP正常处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM