如何阻止 GWTBootstrap3 刷新和丢失我的输入并返回错误代码

How to stop GWTBootstrap3 from refreshing and loosing my input and returning an error code

我正在尝试将 GWTootstrap3 与以下内容一起使用 html:

<div class="row myheader">
    <div class="col-md-4">
        <img class="myimg" alt="Bootstrap Image Preview" src="logo.png" />
    </div>
    <div class="col-md-4">
        <h2> Welcome to the Award Tracker Login Page. </h2>
    </div>
    <div class="col-md-4">
        <img class="myimg  pull-right" alt="Bootstrap Image Preview" src="1stER_icon_256.png" />
    </div>
</div> <!-- /row -->

<div class="row">
    <div class="col-md-12" style="text-align: center;">
        <h3> <a href="https://www.youtube.com/user/GlyndwrBartlett">Instructional videos</a> </h3>
    </div>
</div> <!-- /row -->

<div class="row">
    <div class="col-md-12" style="text-align: center;">
        <h3> <a href="https://www.metawerx.net/">Proudly supported by Metawerx - Specialising in Java hosting since 1997.</a> </h3>
    </div>
</div> <!-- /row -->

<div class="row">
    <div class="col-md-12" style="text-align: center;">
        <button id="privacyPolicy" class="btn btn-large btn-primary" type="submit">Privacy and Security Policy</button>
    </div>
</div> <!-- /row -->

<div class="row">
    <div class="col-md-12">
        <form class="form-signin">
            <h2 class="form-signin-heading">Please sign in</h2>
            <input id="accountName" type="text" class="input-block-level" placeholder="Email address">
            <input id="enterPassword" type="password" class="input-block-level" placeholder="Password">
            <button id="submit" class="btn btn-large btn-primary" type="submit">Sign in</button>
        </form>
    </div>
</div> <!-- /row -->

<div class="row">
    <div class="col-md-12" style="text-align: center;">
        <button id="createAccount" class="btn btn-large btn-primary" type="submit">Create an Account</button>
        <button id="updateAccount" class="btn btn-large btn-primary" type="submit">Update Account</button>
        <button id="forgotPassword" class="btn btn-large btn-primary" type="submit">I forgot my password <img src="sadFace.jpg" width="10" /></button>
    </div>
</div> <!-- /row -->

每当我按下“登录”按钮(或按回车键)时,页面就会刷新并且我丢失了输入的信息。这也会导致错误:

"Throwable value = com.google.gwt.user.client.rpc.StatusCodeException: 0" being returned to the program. How do I stop the page refreshing please? I use the following to call: btnSignIn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) {

因为您正在使用表单,所以页面正在刷新。

你可以这样做:

1)<form> 切换为 <div>

2) 从按钮中删除 type="submit"

到此为止。

GwtBootstrap 表单小部件创建一个真正的 <form> 标记,它会在按下提交按钮或 ENTER 时尝试将您的表单数据提交到表单目标。要防止此行为,请向表单小部件指明:

<b:Form submitOnEnter="false">