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

时间:2017-05-16 04:21:56

标签: html5 gwt gwtbootstrap3

我正在尝试将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 -->

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

  

&#34; Throwable value =   com.google.gwt.user.client.rpc.StatusCodeException:0&#34;被退回   到该计划。请问如何让页面更新?我用   以下致电:       btnSignIn.addClickHandler(new ClickHandler(){public void onClick(ClickEvent event){

2 个答案:

答案 0 :(得分:1)

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

你可以这样做:

1)<form>切换为<div>

2)从按钮

中删除type="submit"

这就是你所做的一切。

答案 1 :(得分:0)

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

<b:Form submitOnEnter="false">