在我的gwt项目中,我使用gwt和gwtbootstrap3。我的代码看起来像
<b:NavbarForm pull="LEFT">
<b:TextBox placeholder="Search" addStyleNames="col-lg-8"/>
</b:NavbarForm>现在,如果我在文本框中键入任何内容并点击enter,gwt将重新加载整个页面,而我不想这样做,我想要的只是从文本框中获取值并调用一个方法。我有没有办法做到这一点。
如果我不使用NavbarForm,我可以获取值,但是我不能使搜索框内联。
http://gwtbootstrap3.github.io/gwtbootstrap3-demo/#navbar
FYI,只是一个更新,如果我将文本框包装在其他容器中,比如NavbarText或NavbarNav,UI就会损坏。
发布于 2015-02-18 08:46:25
这可能是gwtbootstrap3中的一个bug --他们最近对表单小部件进行了一次大修。
但是现在,您可以将一个SubmitHandler添加到您的NavbarForm中,并取消SubmitEvent以防止它重新加载页面:
navbarForm.addSubmitHandler(new SubmitHandler() {
@Override
public void onSubmit(SubmitEvent event) {
event.cancel();
}
});使用UiBinder时:
@UiHandler("navbarForm")
void onNavbarSubmit(SubmitEvent event) {
event.cancel();
}请注意,在本例中,SubmitEvent是org.gwtbootstrap3.client.ui.base.form.AbstractForm.SubmitEvent类型的,不是 com.google.gwt.user.client.ui.FormPanel.SubmitEvent。
https://stackoverflow.com/questions/28572211
复制相似问题