Gwt uiBinder onclick未执行

时间:2011-09-18 18:58:37

标签: java gwt

出于某种原因,我的onClick似乎没有被执行。不打印日志和警报,并且未附加调试器。有什么想法吗?

    @UiHandler("button")
    void onClick(ClickEvent e) {
        GWT.log("Hello!", null);
        Window.alert("Hello!");
    }

整个代码:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
    xmlns:g="urn:import:com.google.gwt.user.client.ui">
    <g:HTMLPanel>
        <div class="statusUpdate">
            <g:TextBox ui:field="textBox">

            </g:TextBox>
            <g:Button ui:field="button" text="Send" />
        </div>
        <div id="validMedia">
            <g:Label ui:field="tCounter" text=""/>
        </div>
    </g:HTMLPanel>
</ui:UiBinder> 

public class StatusUpdate extends Composite implements HasText {

    private static StatusUpdateUiBinder uiBinder = GWT
            .create(StatusUpdateUiBinder.class);

    interface StatusUpdateUiBinder extends UiBinder<Widget, StatusUpdate> {
    }

    public StatusUpdate() {
        initWidget(uiBinder.createAndBindUi(this));
    }

    @UiField
    Button button;

    @UiField 
    TextBox textBox;

    @UiField
    Label tCounter;

    @UiHandler("button")
    void onClick(ClickEvent e) {
        GWT.log("Hello!", null);
        Window.alert("Hello!");
    }

    public void setText(String text) {
        button.setText(text);
    }

    public String getText() {
        return button.getText();
    }
}

Web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

  <!-- Servlets -->

  <!-- Default page to serve -->
  <welcome-file-list>
    <welcome-file>Echo.html</welcome-file>
  </welcome-file-list>

</web-app>

0 个答案:

没有答案