GWT HTML5输入型电话

GWT HTML5输入型电话,html,gwt,Html,Gwt,我有一个GWT应用程序,我的目标是在移动设备上运行。我想使用新的HTML5input type=“tel”来接受电话输入,并让移动设备提示正确的键盘输入(数字) 我正在尝试使用GWT文本框,但找不到让它以正确的输入类型呈现HTML的方法 关于这个有什么想法吗 提前感谢。mgwt()中有许多不同的输入(也是一个电话输入),它是移动设备的GWT。您可能想看看它。简单的方法 TextBox tel=new TextBox(); tel.getElement().setAttribute("type",

我有一个GWT应用程序,我的目标是在移动设备上运行。我想使用新的HTML5
input type=“tel”
来接受电话输入,并让移动设备提示正确的键盘输入(数字)

我正在尝试使用GWT文本框,但找不到让它以正确的输入类型呈现HTML的方法

关于这个有什么想法吗


提前感谢。

mgwt()中有许多不同的输入(也是一个电话输入),它是移动设备的GWT。您可能想看看它。

简单的方法

TextBox tel=new TextBox();
tel.getElement().setAttribute("type", "tel");

TextBox email=new TextBox();
email.getElement().setAttribute("type", "email");

TextBox url=new TextBox();
url.getElement().setAttribute("type", "url");
创建自定义小部件:

package com.example;

import com.google.gwt.dom.client.InputElement;
import com.google.gwt.user.client.ui.TextBoxBase;

public class TelephoneBox extends TextBoxBase {

    public TelephoneBox() {
        super(createTelInput());
    }

    private static native InputElement createTelInput() /*-{
        var input = document.createElement("input");
        input.setAttribute("type", "tel");
        return input;
    }-*/;
}
然后您可以在UiBinder中使用它:

<ui:UiBinder ... xmlns:my="urn:import:com.example">
...
<my:TelephoneBox/>

...

今天查看了此库。很好的一组小部件,谢谢你的推荐。如果在IE上运行,它会出错